Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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
HTML
<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
Posted
Updated 4-Sep-12 9:15am
v2
Comments
[no name] 4-Sep-12 14:54pm    
http://stackoverflow.com/questions/3797593/could-not-determine-a-metatable
jabershamri 4-Sep-12 22:42pm    
no replay
jabershamri 5-Sep-12 9:00am    
plz help

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 ;-)
 
Share this answer
 
changing columns from something like so:

C#
<Columns>
  <asp:DynamicField DataField="Id" HeaderText="Id" />
</Columns>

to this
<pre lang="c#"><Columns>
  <asp:BoundField DataField="Id" HeaderText="Id" />
</Columns>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900