How do I pass a gridview index to an sqldatasource select command?
-
How do I pass a gridview index, as calculated by gridview RowCommand, to an sqldatasource select command? My code is appended. I have a gridview with a Buttonfield with Commandname 'SelectStaff'. On SelectStaff I want to calculate the index of the current row. I have done this successfully using Gridview OnRowCommand event. See method GridView1_RowCommand. I then want to pass the calulated index to the an SqldataSource select command so I can populate a FormView with data whose index is the same as the gridview index. I'm trying to use the Sqldatasource Selectingevent to pick up the index value but with no success. See method SqlDataSource2_Selecting. P.S. I can't use the the GridView CommandField Select as it's already been used. Here's my code: ID:
Name:
private int index = 0; protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectStaff") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32 -
How do I pass a gridview index, as calculated by gridview RowCommand, to an sqldatasource select command? My code is appended. I have a gridview with a Buttonfield with Commandname 'SelectStaff'. On SelectStaff I want to calculate the index of the current row. I have done this successfully using Gridview OnRowCommand event. See method GridView1_RowCommand. I then want to pass the calulated index to the an SqldataSource select command so I can populate a FormView with data whose index is the same as the gridview index. I'm trying to use the Sqldatasource Selectingevent to pick up the index value but with no success. See method SqlDataSource2_Selecting. P.S. I can't use the the GridView CommandField Select as it's already been used. Here's my code: ID:
Name:
private int index = 0; protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectStaff") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32 -
How do I pass a gridview index, as calculated by gridview RowCommand, to an sqldatasource select command? My code is appended. I have a gridview with a Buttonfield with Commandname 'SelectStaff'. On SelectStaff I want to calculate the index of the current row. I have done this successfully using Gridview OnRowCommand event. See method GridView1_RowCommand. I then want to pass the calulated index to the an SqldataSource select command so I can populate a FormView with data whose index is the same as the gridview index. I'm trying to use the Sqldatasource Selectingevent to pick up the index value but with no success. See method SqlDataSource2_Selecting. P.S. I can't use the the GridView CommandField Select as it's already been used. Here's my code: ID:
Name:
private int index = 0; protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectStaff") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32 -
Hi there, In the event handler of the
RowCommand
event of the GridView control, you simply call theDataBind
method of theFormView
control, and as a result of that theSelecting
event of the second SqlDataSource control gets fired.