if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("OnDblClick", "'"+this.TextBox3.Text+"'='" + e.Row.Cells[2].Text + "'"); }我想实现点击此行 把此行的一个字段或第三个单元格的值赋给this.TextBox3.Text上面的写法好像不对 上面第三个单元格 数据库里的字段名是ConsumerName
{
e.Row.Attributes.Add("OnDblClick", "'"+this.TextBox3.Text+"'='" + e.Row.Cells[2].Text + "'"); }我想实现点击此行 把此行的一个字段或第三个单元格的值赋给this.TextBox3.Text上面的写法好像不对 上面第三个单元格 数据库里的字段名是ConsumerName
<script language="javascript">
function SetTextBox(text)//TextBox赋值
{
var txt=document.getElementById("TextBox1");
txt.value=text;
}
</script>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("OnDblClick", "SetTextBox('" + e.Row.Cells[2].Text + "')");//添加JS事件 } }
{
e.Row.Attributes.Add ( "OnDblClick", "document.getElementById('TextBox3').value='"+e.Row.Cells[2].Text+"'" );
}这样可以