This is a migrated thread and some comments may be shown as answers.

Setting row visibility

1 Answer 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Regeesh Joseph
Top achievements
Rank 1
Regeesh Joseph asked on 05 Aug 2010, 10:12 AM
Hai,

I have a dataset in the following way which is bound to a radgrid.

Id       Name
--------------------
1        USA
2        UK
3        FRANCE

I have one tab strip with 3 tabs USA,UK,FRANCE.  On clicking the UK tab, only the row which contains UK should be visible.

Is there any way?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Aug 2010, 11:09 AM
Hi Regeesh,


One option to accomplish this is populating the grid based on TabStrip selection.

In the "TabClick" event of RadTabStrip, Rebind() the grid, which in turn fires the OnNeedDataSource event of grid. Now in the OnNeedDataSource event get RadTabStrip's selected item value and populate the grid according to the value.

The code will be similar as shown below.

protected void RadGrid1_NeedDataSource(object  source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
 OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/Nwind.mdb"));
 OleDbDataAdapter adapter = new OleDbDataAdapter();
 string query = "SELECT * FROM Customers WHERE name="+ RadTabStrip1.SelectedTab.Value;
 adapter.SelectCommand = new OleDbCommand(query, conn);
 DataTable myDataTable = new DataTable();
 conn.Open();
 try
 {
    adapter.Fill(myDataTable);
 }
 finally
 {
    conn.Close();
 }
 RadGrid1.DataSource = myDataTable;
}



-Shinu.
Tags
Grid
Asked by
Regeesh Joseph
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or