
c# GridView怎么把选择的谋行全部载入TextBox 里,web网站,新人求具体步骤。
展开全部
dgvEventData 为 GridView控件。添加Click事件
private void dgvEventData_Click(object sender, EventArgs e)
{
if (dgvEventData.DataSource == null)
return;
int selectindex = dgvEventData.SelectedCells[0].RowIndex; //选中行
if (selectindex >= 0)
{
txtDateTime.Text = dgvEventData.CurrentRow.Cells["日期"].Value.ToString(); //日期为GridView中的列名
txtText.Text = dgvEventData.CurrentRow.Cells["内容"].Value.ToString();
//内容为列名
txtTitle.Text = dgvEventData.CurrentRow.Cells["标题"].Value.ToString();
txtSubtitle.Text = dgvEventData.CurrentRow.Cells["subtitle"].Value.ToString();
string name = dgvEventData.CurrentRow.Cells["ImageName"].Value.ToString();
string ID = dgvEventData.CurrentRow.Cells[0].Value.ToString(); //第0列
// string ID = dgvEventData.CurrentRow.Cells["编号"].Value.ToString();
//这里告诉你可以使用列名也可以使用 下标来表示第几列
}
}
private void dgvEventData_Click(object sender, EventArgs e)
{
if (dgvEventData.DataSource == null)
return;
int selectindex = dgvEventData.SelectedCells[0].RowIndex; //选中行
if (selectindex >= 0)
{
txtDateTime.Text = dgvEventData.CurrentRow.Cells["日期"].Value.ToString(); //日期为GridView中的列名
txtText.Text = dgvEventData.CurrentRow.Cells["内容"].Value.ToString();
//内容为列名
txtTitle.Text = dgvEventData.CurrentRow.Cells["标题"].Value.ToString();
txtSubtitle.Text = dgvEventData.CurrentRow.Cells["subtitle"].Value.ToString();
string name = dgvEventData.CurrentRow.Cells["ImageName"].Value.ToString();
string ID = dgvEventData.CurrentRow.Cells[0].Value.ToString(); //第0列
// string ID = dgvEventData.CurrentRow.Cells["编号"].Value.ToString();
//这里告诉你可以使用列名也可以使用 下标来表示第几列
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询