Select a row of DataGrid

shahab

Junior Contributor
Joined
Aug 14, 2003
Messages
206
Location
Iran(Middle East)
I have a DadtaGrid like this:
dg01.gif


1st Q:Pressing the Choose user>In which event(PageInsdexChanged?) , what should I write in order to select and save the value of username column in a session?

***************************************************

2nd Q:Pressing the usename in dg >In which event (SelectedIndexChanged?) ,what shoud I write in order to select and save the value of username column in a session?

Many thanks:)
dg02.gif
 
1st Q: for the button put a commandname
on itemcommand event
if e.commandname= yourcommand
session("x") = e.Item.Cells(0)
 
what about this method?
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
try
{
Session["username"]=DataGrid1.DataKeys[(int)e.Item.ItemIndex].ToString();
Response.Redirect("2.aspx");
}
catch(Exception e2)
{
Label3.Text=e2.Message.ToString();
}
}

2nd Q;??? :p
 
Back
Top