Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have make gridview from and then right the code to take the data from database.
but this is only showing gridview and column name bu there is no data
please help me with that.

XML
<asp:GridView ID="GridView1" runat="server"
           onrowcommand="GridView1_RowCommand" onrowdeleted="GridView1_RowDeleted"
           onrowediting="GridView1_RowEditing" onrowupdated="GridView1_RowUpdated"
           onselectedindexchanged="GridView1_SelectedIndexChanged"
           AutoGenerateColumns="False" onrowcreated="GridView1_RowCreated"
           style="margin-bottom: 0px">
           <Columns>
           <asp:TemplateField HeaderText="Rack No">
           <EditItemTemplate>
               <asp:TextBox ID="TextBoxEditrackno" runat="server" Text='<%# Bind("rackno") %>'/>
           </EditItemTemplate>
           <%--<ItemTemplate>
               <asp:Label ID="LabelRackNo" runat="server" Text='<%# Bind("Rack No") %>'/>
           </ItemTemplate>--%>
           <FooterTemplate>
               <asp:TextBox ID="TextBoxrackno" runat="server"/>
           </FooterTemplate>
       </asp:TemplateField >
       <asp:TemplateField HeaderText="Rack Name">
           <EditItemTemplate>
               <asp:TextBox ID="TextBoxEditrname" runat="server" Text='<%# Bind("rname") %>'/>
           </EditItemTemplate>
           <%--<ItemTemplate>
               <asp:Label ID="Labelrname" runat="server" Text='<%# Bind("rname") %>'/>
           </ItemTemplate>--%>
           <FooterTemplate>
               <asp:TextBox ID="TextBoxrname" runat="server"/>
           </FooterTemplate>
       </asp:TemplateField >
       <asp:TemplateField HeaderText="Quantity">
           <EditItemTemplate>
               <asp:TextBox ID="TextBoxEditqty" runat="server" Text='<%# Bind("qty") %>'/>
           </EditItemTemplate>
           <%--<ItemTemplate>
               <asp:Label ID="Labelqty" runat="server" Text='<%# Bind("qty") %>'/>
           </ItemTemplate>--%>
           <FooterTemplate>
               <asp:TextBox ID="TextBoxrqty" runat="server"/>
           </FooterTemplate>
       </asp:TemplateField >
















C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                binddata();
            }

        }
        private void binddata()
        {
            string connstring = @"Data Source=LENOVO-41B3F2CE\SQLEXPRESS;Initial Catalog=IMS;Integrated Security=True;Pooling=False";
            string query = "SELECT * FROM ['ISB VAS Nodes$']";
            SqlDataAdapter da = new SqlDataAdapter(query, connstring);
            DataTable dt = new DataTable();
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
Posted
Updated 18-Apr-13 0:44am
v2
Comments
Zafar Sultan 18-Apr-13 6:46am    
Whats the error on removing comments from ItemTemplate?
fak_farrukh 18-Apr-13 6:55am    
"A call to Bind was not well formatted. Please refer to documentation for the correct parameters to Bind"
that was the error

1 solution

hi,

Remove comment from item template
 
Share this answer
 
Comments
fak_farrukh 18-Apr-13 6:40am    
when i remove that i give error
fak_farrukh 18-Apr-13 6:54am    
"A call to Bind was not well formatted. Please refer to documentation for the correct parameters to Bind"
that was the error

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