Hi,
I have 2 supparte GridView Controls name called GridViewOne, GridViewTwo
i want to get GridviewOne's Datakeynames in GridViewTwo RowEditing,RowUpdating
Please hlep me.
Use this Technique:
int index;
string datakey1,datakey2;
protected void gv1_RowEditing(object sender, GridViewEditEventArgs e)
{
// for point out specific index.
index =e.RowIndex;
}
protected void gv2_RowEditing(object sender, GridViewEditEventArgs e)
{
datakey1=gv1.DataKeys[index].Values[0];
//datakey2=gv1.DataKeys[index].Values[1];
}
Hi, Thanks for reply
I want to edit gv2 not gv1, gv1_RowEditing will not fire, and i'm not able to get e.RowIndex in Gv1
Use this:
int index;
protected void gv2_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
index = Convert.ToInt32(e.NewSelectedIndex);
}
//Now you get value any where using below code.
foreach (GridViewRow row in GridView1.Rows)
{
int ID = Convert.ToInt32(GridView1.DataKeys[index].Values[0]);
string name = GridView1.DataKeys[index].Values[1].ToString();
}
沒有留言:
張貼留言