"HaVoK" <ha**********@googlemail.comwrote in message
news:11********************@i3g2000cwc.googlegroup s.com...
my problem: i want to get the values of the selected rows of a
GridView.
No problem.
I have a button in every row
You don't actually need a button to select a row - just clicking on it
selects it...
and want to get the actual values e.g. of cell 1 of the actual row.
How can i get this value?
I am using VS 2005 and VB.
The following code is in C#, but it should guide you through the process..
<asp:GridView ID="MyGridView" runat="server"
OnRowDataBound="MyGridView_RowDataBound"
OnSelectedIndexChanged="MyGridView_SelectedIndexCh anged">
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(MyGridView, "Select$" +
e.Row.RowIndex.ToString()));
e.Row.Style["cursor"] = "pointer";
}
}
protected void MyGridView_SelectedIndexChanged(object sender, EventArgs e)
{
string strFirstCell = MyGridView.SelectedRow.Cells[0].Text;
}