Click here to Skip to main content
12,071,437 members (35,275 online)
Rate this:
 
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") %>'/>















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 18-Apr-13 6:46am
   
Whats the error on removing comments from ItemTemplate?
Member 7909184 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 18-Apr-13 6:40am
   
when i remove that i give error
Member 7909184 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2016
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