在GridView的RowDataBound事件里写代码。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("OnDblClick", "JavaScript:document.all('" + textbox1.ClientID + "').value = 'post_code';document.all('" + textbox2.ClientID + "').value = 'post_name;'");
}
}
在dataGridView的DoubleClick事件里面这样写
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
textbox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
textbox2.Text=dataGridView1.CurrentRow.Cells[1].Value.ToString();
}