获取 GridView 中控件的值
int id = Convert.ToInt32(((HiddenField)GridView1.Rows[i].FindControl("_id")).Value)
string s = ((DropDownList)GridView1.Rows[i].FindControl("_s")).SelectedValue;
演示了两个示例,一个是 HiddenField,一个是 DropDownList。[i] 是行索引。
获取 GridView 中单元格的文字
string fullName = GridView1.Rows[i].Cells[1].Text;
[i] 是行索引,[1] 是列索引。
注意
若是回传值,GridView 的 EnableViewState 应为 true 才有效。