Hi,
I am busy doing R&D to see if the RadGrid will work for us. So far it has been working fine, but I am struggling to retrieve a selected row's column names and values similar to the way you would do that for a DataTable. However, the e.Item.DataSetIndex appears to return the index of the current grid, not the entire datatable bound to it which is incorrect for m purposes. I am using standard paging of 10 rows per page. I need a way to get hold of one or more column values for the current row selected, either by looking at the databable with the correct row index (as I have tried) or directly in the grid row itself.
The way I am implementing the RadGrid includes the following:
1. Making use of AutoGeneratedColumns
2. Binding DataTable to RadGrid followed by DataBind() event.
3. Subscribed to event handler OnNeedDataSource to rebind grid on postback.
4. Subscribed to event handler OnItemCommand to try and retrieve current row's values as described.
Here's a basic overview of my page class:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
//Instantiate Buss Object
buss_Menus = new CS_Business.CS_Menus(Session.SessionID);
//Select Menu(s) from DB
ds = buss_Menus.Select();
Session["dataview_menus_list"] = ds.Tables[0].DefaultView;
dv = (DataView)Session["dataview_menus_list"];
rgDataGrid.DataSource = dv;
rgDataGrid.DataBind();
}
protected void rgDataGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
dv = (DataView)Session["dataview_menus_list"];
rgDataGrid.DataSource = dv;
}
protected void rgDataGrid_ItemCommand(object source, GridCommandEventArgs e)
{
DataView dv = (DataView)Session["dataview_menus_list"];
DataRow dr = dv.Table.Rows[e.Item.DataSetIndex];
string mnuName = dr["FRONTEND_NAME"].ToString(); //This is where the problem is right now
}
Any help here would be appreciated.
Stefan Buys
I am busy doing R&D to see if the RadGrid will work for us. So far it has been working fine, but I am struggling to retrieve a selected row's column names and values similar to the way you would do that for a DataTable. However, the e.Item.DataSetIndex appears to return the index of the current grid, not the entire datatable bound to it which is incorrect for m purposes. I am using standard paging of 10 rows per page. I need a way to get hold of one or more column values for the current row selected, either by looking at the databable with the correct row index (as I have tried) or directly in the grid row itself.
The way I am implementing the RadGrid includes the following:
1. Making use of AutoGeneratedColumns
2. Binding DataTable to RadGrid followed by DataBind() event.
3. Subscribed to event handler OnNeedDataSource to rebind grid on postback.
4. Subscribed to event handler OnItemCommand to try and retrieve current row's values as described.
Here's a basic overview of my page class:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
//Instantiate Buss Object
buss_Menus = new CS_Business.CS_Menus(Session.SessionID);
//Select Menu(s) from DB
ds = buss_Menus.Select();
Session["dataview_menus_list"] = ds.Tables[0].DefaultView;
dv = (DataView)Session["dataview_menus_list"];
rgDataGrid.DataSource = dv;
rgDataGrid.DataBind();
}
protected void rgDataGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
dv = (DataView)Session["dataview_menus_list"];
rgDataGrid.DataSource = dv;
}
protected void rgDataGrid_ItemCommand(object source, GridCommandEventArgs e)
{
DataView dv = (DataView)Session["dataview_menus_list"];
DataRow dr = dv.Table.Rows[e.Item.DataSetIndex];
string mnuName = dr["FRONTEND_NAME"].ToString(); //This is where the problem is right now
}
Any help here would be appreciated.
Stefan Buys