Asp.net GridView Clickable Row [英] Asp.net GridView Clickable Row

查看:86
本文介绍了Asp.net GridView Clickable Row的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中的某些表中将值绑定到GridView。



我使用的代码如下:



  public   void  gridfill()
{
尝试
{
reader = obj.SelCommand( 选择id作为Code,client_name作为客户端从tbl_client order by cast(id as int));
使用(读者)
{
DataTable dt = new DataTable ();
dt.Load(读者);
grdCompany.DataSource = dt;
grdCompany.DataBind();
}
catch (例外情况)
{
Response.Write( 页面错误: + ex.Message);
}
}





现在我得到了正确的结果:



1 GMA

2 TEC

3 ERT

4 LVV



等....



现在我的问题是我想把第一个细胞Clickable,我想在点击中做一些编码该单元格值的事件。



我该怎么做?请帮助我

解决方案

这个 [ ^ ]可能会对您有所帮助。


可能会这样做帮助你更多



 受保护  void  PeopleGridView_RowDataBound( object  sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes [ onmouseover] = this.style.cursor ='手 '; this.style.textDecoration =' 下划线';;
e.Row.Attributes [ onmouseout] = this.style.textDecoration ='none';;
e.Row.Attributes [ onclick] = ClientScript.GetPostBackClientHyperlink( this .PeopleGridView, 选择


< blockquote> + e.Row.RowIndex);
}
}





您可以在以下2个链接中找到更多关于您的问题的内容

[链接1 ]

[ Link 2 ^ ]

I am binding values to GridView from some tables in DB.

The code i used for this is following:

public void gridfill()
{
 try
  {
  reader = obj.SelCommand("Select id as Code,client_name as Client from tbl_client order by cast(id as int)");
  using (reader)
  {
    DataTable dt = new DataTable();
    dt.Load(reader);
    grdCompany.DataSource = dt;
    grdCompany.DataBind();
   }
  catch (Exception ex)
  {
   Response.Write("Error in Page:" + ex.Message);
  }
    }



Now am getting correct result like this:

1 GMA
2 TEC
3 ERT
4 LVV

etc....

Now my question is I WANT TO MAKE THE FIRST CELL "Clickable" and i want to do some coding in the click event of that cell value.

How can i do this?please help me

解决方案

This[^] may help you.


may be this will help you more

protected void PeopleGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
            e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
            e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.PeopleGridView, "Select


" + e.Row.RowIndex); } }



you can find more stuff about your question on below 2 links
[Link 1]
[Link 2^]


这篇关于Asp.net GridView Clickable Row的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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