title: grid view does not show data from database once bind
body: <p>I have a grid view it has 3 drop down lists and 3 text boxes in template field. On the top of the grid view i have two text boxes( text box 1 and 2) which initilize there values when page is loaded. i also have 3 buttons for add new row , save , search. I want my grid view to show data from database when search button is clicked i.e select * from table where text box 1 and 2 equal to some thing. My HTML looks like.</p>
  
  <p>
  
  <pre><code>    AutoGenerateColumns="false"        onselectedindexchanged="Gridview1_SelectedIndexChanged" BackColor="White" 
          BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" 
          GridLines="Horizontal"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="RowNumber" HeaderText="Row Number" /&gt;
              &lt;asp:TemplateField HeaderText="Item name"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:DropDownList ID="DropDownList1" runat="server" Height="25px" Width="119px" 
            DataTextField = "Item_name" Text='&lt;%# Bind("Item_name") %&gt;'   DataValueField="Item_name" 
                           AppendDataBoundItems="true"&gt;
                      &lt;/asp:DropDownList&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Sub item"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:DropDownList ID="DropDownList2" runat="server" Height="25px" Width="119px" 
                 AppendDataBoundItems="true"   
                           DataValueField = "Sub_item" Text='&lt;%# DataBinder.Eval(Container, "DataItem.Sub_item") %&gt;'  DataTextField = "Sub_item"
                             /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Location"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# DataBinder.Eval(Container, "DataItem.Location") %&gt;' &gt;&lt;/asp:TextBox&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Permit number"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox2" runat="server"  Text='&lt;%# DataBinder.Eval(Container, "DataItem.Permit no") %&gt;' &gt;&lt;/asp:TextBox&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Applied"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:DropDownList ID="DropDownList3" runat="server"
  
              Height="25px" Width="119px" 
              DataTextField="Text" AppendDataBoundItems="true" Text='&lt;%# DataBinder.Eval(Container, "DataItem.Applied") %&gt;'  DataValueField="Value"  /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Revision"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox3" runat="server"  Text='&lt;%# DataBinder.Eval(Container, "DataItem.Revision") %&gt;' &gt;&lt;/asp:TextBox&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterStyle HorizontalAlign="Right" /&gt;
                  &lt;FooterTemplate&gt;
                      &lt;asp:Button ID="ButtonSave" runat="server"  Text="Save" OnClick="Save_Click" /&gt;
                      &lt;asp:Button ID="ButtonAdd" runat="server"  Text="Add Row" /&gt;
                      &lt;asp:Button ID="search" runat="server"  Text="Search"  OnClick="Search_Click"/&gt;
  
                  &lt;/FooterTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
  </code></pre>
  
  <p>on my search button click i have this code</p>
  
  <pre><code>     if (TextBox4.Text != null &amp;&amp; TextBox5.Text != null)
           {
               string job = TextBox4.Text.ToString();
               string leg = TextBox5.Text.ToString();
               string connString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
               using (var conn = new SqlConnection(connString))
               using (var cmd = conn.CreateCommand())
               {
                   Response.Write(job);
                   Response.Write(leg);
                   conn.Open();
                   SqlCommand comand = new SqlCommand("SELECT * from Billing_heads where job# = '" + job + "' AND leg#='" + leg + "' ", conn);
                  // try
                   //{
                       SqlDataAdapter adp = new SqlDataAdapter(comand);
                       DataSet ds = new DataSet();
                       adp.Fill(ds);
                       //gvPros is the ID of GridView.
                       Gridview1.DataSource = ds;
                       Gridview1.DataBind();
  </code></pre>
  
  <p>Please help me that how can i bind my gridview because in Text='&lt;%# Bind("Item_name") %>'  property it saying the column name it says property with  name "coloumn name " does not exists please help</p>