Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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.
 
<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 >
 

 

 

 

 

 

 

 
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 18-Apr-13 1:37am
Edited 18-Apr-13 1:44am
v2
Comments
Zafar Sultan at 18-Apr-13 6:46am
   
Whats the error on removing comments from ItemTemplate?
Member 7909184 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
 
Remove comment from item template
  Permalink  
Comments
Member 7909184 at 18-Apr-13 6:40am
   
when i remove that i give error
Member 7909184 at 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)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100