GridView 编辑提交时怎么取当前TextBox中的值?
展开全部
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//dataGridView1行数索引如果大于等于0说明有数据存在
if (e.RowIndex >= 0)
{
this.qyid.Text = dataGridView1.CurrentRow.Cells["列名8"].Value.ToString().Trim();
this.qymc.Text = dataGridView1.CurrentRow.Cells["列名7"].Value.ToString().Trim();
this.qyjp.Text = dataGridView1.CurrentRow.Cells["列名6"].Value.ToString().Trim();
this.qydz.Text = dataGridView1.CurrentRow.Cells["列名5"].Value.ToString().Trim();
this.lxr.Text = dataGridView1.CurrentRow.Cells["列名4"].Value.ToString().Trim();
this.lxfs.Text = dataGridView1.CurrentRow.Cells["列名3"].Value.ToString().Trim();
this.sss.Text = dataGridView1.CurrentRow.Cells["列名2"].Value.ToString().Trim();
this.ssqx.Text = dataGridView1.CurrentRow.Cells["列名1"].Value.ToString().Trim();
}
else
{
MessageBox.Show("无信息显示!");
}
}
更新一下就可以了,以上是单击GridView时获取单元值格式
{
//dataGridView1行数索引如果大于等于0说明有数据存在
if (e.RowIndex >= 0)
{
this.qyid.Text = dataGridView1.CurrentRow.Cells["列名8"].Value.ToString().Trim();
this.qymc.Text = dataGridView1.CurrentRow.Cells["列名7"].Value.ToString().Trim();
this.qyjp.Text = dataGridView1.CurrentRow.Cells["列名6"].Value.ToString().Trim();
this.qydz.Text = dataGridView1.CurrentRow.Cells["列名5"].Value.ToString().Trim();
this.lxr.Text = dataGridView1.CurrentRow.Cells["列名4"].Value.ToString().Trim();
this.lxfs.Text = dataGridView1.CurrentRow.Cells["列名3"].Value.ToString().Trim();
this.sss.Text = dataGridView1.CurrentRow.Cells["列名2"].Value.ToString().Trim();
this.ssqx.Text = dataGridView1.CurrentRow.Cells["列名1"].Value.ToString().Trim();
}
else
{
MessageBox.Show("无信息显示!");
}
}
更新一下就可以了,以上是单击GridView时获取单元值格式
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询