无法确定MetaTable。 [英] Could not determine a MetaTable.

查看:184
本文介绍了无法确定MetaTable。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我添加了gridview来显示一些表格数据

,但是当我运行页面时它会给我这个消息



无法确定MetaTable。无法确定数据源'SqlDataSource1'的MetaTable,并且无法从请求URL推断出MetaTable。确保表已映射到dats源,或者数据源配置了有效的上下文类型和表名,或者请求是已注册的DynamicDataRoute的一部分。



这是我的完整代码

hi for all i added gridview to show some table data
,but when I run the page it give me this message

Could not determine a MetaTable. A MetaTable could not be determined for the data source 'SqlDataSource1' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.

and this is my full code

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                                               CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
                                               GridLines="None" style="text-align: center" Width="100%"
                                           DataKeyNames="ID_Specialized" onrowcommand="GridView1_RowCommand"
                                               >
                               <alternatingrowstyle backcolor="White" forecolor="#284775" />
                               <columns>
                                   <asp:DynamicField DataField="Specialized_Name" HeaderText="name" />
                                   <asp:DynamicField DataField="Degree" HeaderText="grade" />
                                   <asp:DynamicField DataField="current_work" HeaderText="current work" />
                                   <asp:TemplateField ShowHeader="False">
                                       <itemtemplate>
                                           <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False"
                                                           CommandArgument='<%# Eval("ID_Specialized") %>' CommandName="Select"
                                                           ImageUrl="~/images/newsletter_emailtemplate.gif"
                                                           oncommand="ImageButton1_Command" Text="Select" />
                                       </itemtemplate>

                               </columns>
                               <HeaderStyle  Font-Bold="True" ForeColor="#5D7B9D" CssClass="txt22" />
                               <pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center" />
                               <rowstyle backcolor="#F7F6F3" forecolor="#333333" cssclass="txt2" />
                               <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                               <sortedascendingcellstyle backcolor="#E9E7E2" />
                               <sortedascendingheaderstyle backcolor="#506C8C" />
                               <sorteddescendingcellstyle backcolor="#FFFDF8" />
                               <sorteddescendingheaderstyle backcolor="#6F8DAE" />


                           <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                               ConnectionString="<%$ ConnectionStrings:ContinueConnectionString %>"
                               SelectCommand="SELECT * FROM [Specialized]">
       <td removed="./css_files/r.gif">
       </td>

   <tr>
       <td>
           <img src="./css_files/d-l.gif" width="8" height="9"></td>
       <td removed="./css_files/d.gif" colspan="2">
           <asp:SqlDataSource ID="SqlDataSource2" runat="server"
               ConnectionString="<%$ ConnectionStrings:ContinueConnectionString %>"
               SelectCommand="SELECT * FROM [Specialized]">



任何人都可以帮助我很多谢谢


any one can help me many thanks

推荐答案

ConnectionStrings :ContinueConnectionString%>
< span class =code-attribute> SelectCommand=\"SELECT * FROM [Specialized]\">
<td removed=\"./css_files/r.gif\">
</td>

<tr>
<td>
<img src=\"./css_files/d-l.gif\" width=\"8\" height=\"9\"></td>
<td removed=\"./css_files/d.gif\" colspan=\"2\">
< asp:SqlDataSource ID=\"SqlDataSource2\" runat=\"server\"
ConnectionString=\"<%
ConnectionStrings:ContinueConnectionString %>" SelectCommand="SELECT * FROM [Specialized]"> <td removed="./css_files/r.gif"> </td> <tr> <td> <img src="./css_files/d-l.gif" width="8" height="9"></td> <td removed="./css_files/d.gif" colspan="2"> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%


ConnectionStrings:ContinueConnectionString %>\"
SelectCommand=\"SELECT * FROM [Specialized]\">
ConnectionStrings:ContinueConnectionString %>" SelectCommand="SELECT * FROM [Specialized]">



any one can help me many thanks


any one can help me many thanks


Quote:

For me, it turns out that in my grid view, the columns were bound as an \"asp:DynamicField\", not as a \"asp:BoundField\"



ie



changing my columns from something like so:



<columns> <asp:dynamicfield datafield=\"Id\" headertext=\"Id\" xmlns:asp=\"#unknown\">

to this:



<columns> <asp:boundfield datafield=\"Id\" headertext=\"Id\" xmlns:asp=\"#unknown\">

fixed it ;-)

For me, it turns out that in my grid view, the columns were bound as an "asp:DynamicField", not as a "asp:BoundField"

ie

changing my columns from something like so:

<columns> <asp:dynamicfield datafield="Id" headertext="Id" xmlns:asp="#unknown">
to this:

<columns> <asp:boundfield datafield="Id" headertext="Id" xmlns:asp="#unknown">
fixed it ;-)


这篇关于无法确定MetaTable。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆