protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList drop = sender as DropDownList; GridViewRow row = drop.Parent.Parent as GridViewRow; int id; int.TryParse(row.Cells[0].Text, out id);//直接 //int id = GridView1.DataKeys[row.RowIndex].Value.ToString(); //如果设置了GridView的主键为id的话,用这句取id }
或者是gridview.datakeys[i].defaultvalues;
大水写你自己改以下。如有不明白的我会继续回答的。前几天我也用到的。呵呵
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList drop = sender as DropDownList;
GridViewRow row = drop.Parent.Parent as GridViewRow;
int id;
int.TryParse(row.Cells[0].Text, out id);//直接
//int id = GridView1.DataKeys[row.RowIndex].Value.ToString();
//如果设置了GridView的主键为id的话,用这句取id
}