1

how to fill table/grid through unbound control using ADO.NET C#.

    using (SqlConnection Connection = new SqlConnection())
    {
        Connection.ConnectionString = ConnectionString;
        Connection.Open();

        SqlDataAdapter Adapter = new SqlDataAdapter(Query + ItemIndex, Connection);
        DataSet DataSet = new DataSet();

        Adapter.Fill(DataSet);
        unbndgrdRecord.DataSource = DataSet;
        unbndgrdRecord.DataBind();
    }

this is the code i want to convert this in unbound control...

Mubashir Ali
  • 559
  • 2
  • 8
  • 23
  • Need some more information. If `unbndgrdRecord` is a GridView, this code should work. If not, what type of control is `unbndgrdRecord`? – Garrison Neely Jul 11 '13 at 22:15
  • this code works perfectly but lately I come to know this is databound control code not unbound control an unbound control is that which doesn't have a data source. – Mubashir Ali Jul 11 '13 at 22:20
  • I don't understand what your question is. Any control meant to display data (GridView, Repeater, DetailsView, etc) is worthless until it is bound to a data source. In your code above you are filling what I assume is a GridView with data. Until you call `DataBind();` the GridView is unbound. What are you trying to accomplish? – Garrison Neely Jul 11 '13 at 22:23
  • i am trying that on clicking the search button, the program should query/search all child records that are related to the selected parent record and return details in the table/grid (or any other control that shows tabular data) using unbounded control the given code is of bound control which is of no use. – Mubashir Ali Jul 11 '13 at 22:31
  • 3
    Now I understand. Your problem is very common and you should be able to find a lot of tutorials. The `GridView` and `DetailsView` were designed with this case in mind. Here's a tutorial I found on MSDN you can use: http://msdn.microsoft.com/en-us/library/aa581796.aspx – Garrison Neely Jul 11 '13 at 22:34

0 Answers0