日期:2014-05-18  浏览次数:20481 次

如何在GridView中选定行读取其中的某个字段到文本框中?
rt

------解决方案--------------------
添加CellClick事件
private void dataGridViewPlan_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
return;
if (e.ColumnIndex < 0)
return;

string bb= dataGridViewPlan["columnName", e.RowIndex];
}
------解决方案--------------------
在GridView上应有一个选择LinkButton,则在GridView1的SelectedIndexChanged事件下输入:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = GridView1.Rows[GridView1.SelectedIndex].Cells[列号].Text;
}

------解决方案--------------------
你想在什么事件中选中行?
------解决方案--------------------
探讨
在GridView上应有一个选择LinkButton,则在GridView1的SelectedIndexChanged事件下输入:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = GridView1.Rows[GridView1.SelectedIndex].Cells[列号].Text;
}