如何在GridView上双击行时获取id [英] How do I get id when double click row on GridView

查看:146
本文介绍了如何在GridView上双击行时获取id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各个团体,

i有一个gridview:

----------------------- ----

id代码名称

---------------------------

01 c1 name1

02 c2 name2

-------------------- -------
我写的代码中的


protected void grvOutput_RowDataBound(object sender,GridViewRowEventArgs e)

{

if(e.Row.RowType == DataControlRowType.DataRow)

{

e.Row.Attributes.Add(ondblclick,javascript :window.open('ColorInput.aspx','_ parent'););

}

}



双击gridview之前,我如何得到每一行的id(01; 02)?

i used:

string id =((Label)e.Row .Cells [1] .FindControl(id))。文字;

但没有选择行。

谢谢!

hi every body,
i have a gridview:
---------------------------
id code name
---------------------------
01 c1 name1
02 c2 name2
---------------------------
in code behind i write:
protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick", "javascript: window.open('ColorInput.aspx','_parent');");
}
}

before double click on gridview, how i get id of each row (01; 02)?
i used:
string id = ((Label)e.Row.Cells[1].FindControl("id")).Text;
but not get row selected.
thanks!

推荐答案

带有GridView和DataList控件的可点击和双击行(ASP.NET 2.0) [ ^ ]


在rowdatabound:



In rowdatabound:

protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        string id = e.Row.Cells[0].Text;
    }
}





或者,对于单击/选择,您可以使用SelectedIndexChanged < br $> b $ b



Or, for single click/selection, you could use SelectedIndexChanged

protected void grvOutput_SelectedIndexChanged(object sender, EventArgs e)
{
      string id = grvOutput.SelectedRow.Cells[0].Text;
}


如果我使用

If i use
protected void grvOutput_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           string id = e.Row.Cells[0].Text;
       }
   }



未获得行选择



是的,如果我使用


it not get row selected.

Yes, if i used

protected void grvOutput_SelectedIndexChanged(object sender, EventArgs e)
{
      string id = grvOutput.SelectedRow.Cells[0].Text;
}



没关系,但我要双击行,而不是单击。



非常感谢。


it 's ok, but i want double click on row, not single click.

thank you very much.


这篇关于如何在GridView上双击行时获取id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆