Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every body,
i have a gridview:
---------------------------
id code name
---------------------------
01 c1 name1
02 c2 name2
---------------------------
in code behind i write:
protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick", "javascript: window.open('ColorInput.aspx','_parent');");
}
}

before double click on gridview, how i get id of each row (01; 02)?
i used:
string id = ((Label)e.Row.Cells[1].FindControl("id")).Text;
but not get row selected.
thanks!
Posted

In rowdatabound:

C#
protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        string id = e.Row.Cells[0].Text;
    }
}


Or, for single click/selection, you could use SelectedIndexChanged

C#
protected void grvOutput_SelectedIndexChanged(object sender, EventArgs e)
{
      string id = grvOutput.SelectedRow.Cells[0].Text;
}
 
Share this answer
 
If i use
C#
protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           string id = e.Row.Cells[0].Text;
       }
   }

it not get row selected.

Yes, if i used
C#
protected void grvOutput_SelectedIndexChanged(object sender, EventArgs e)
{
      string id = grvOutput.SelectedRow.Cells[0].Text;
}

it 's ok, but i want double click on row, not single click.

thank you very much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900