Dear Nathan,
thanks for the reply, but how can I use your code to perform certain actions when the button is clicked ?
The "btnAdd" ID is the same for all the buttons in all the rows, since I'm using a template.
I need is to use a certain Select property (like SelectedIndex) to retrieve the row of the clicked button, and to put all the code in the button on click event.
But the following code, which I put in the on click event, does not work :
Dim grd As GridView = FormView1.FindControl("myGridView")
Dim row As GridViewRow = grd.Rows(grd.SelectedIndex)
Dim str As String = row.cells(column_index).Text.ToString()
What's wrong with it ?[/quote]
Try this.
Add a CommandName to your button like CommandName = "Add".
Then in the RowCommand event use an if statement to see if the CommandName is = to "Add".
If it is use your code above
Like this
- protected void myGridView_RowCommand(object sender, GridViewCommandEventArgs e)
-
{
-
if(e.CommandName == "Add")
-
{
-
GridView grd = FormView1.FindControl("myGridView");
-
GridViewRow row = grd.Rows[grd.SelectedIndex];
-
string str = row.cells[column_index].Text.ToString();
-
}
-
}
Let me know if this works for you. If you need a conversion tool you can use this
site.
Nathan