我怎样才能识别GridView中编辑一行? [英] How can I identify the edited row in GridView?

查看:96
本文介绍了我怎样才能识别GridView中编辑一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户希望在GridView只显示文本框里面的字段,以及DropDownListBoxes。他想要的灵活性,只需点击更新按钮在细胞改变后的值更新记录。

My client wanted the GridView to display fields inside TextBoxes, and DropDownListBoxes only. He wanted the flexibility to update the Record just by clicking on the Update button after altering the values in the cell.

他想在一些不同的颜色在当前编辑GridViewRow,这样他就可以更新按钮,单击该特定行。

He wanted the current editing GridViewRow in some different color so that he can click on "Update" button for that particular row.

我如何能识别在GridView当前编辑行?由于没有编辑按钮点击!!

How can I identify the current editing row in the GridView? Since there is no edit button to click on!!

推荐答案

您可以使用此code选择该行,并表现出不同的颜色行。
u能突出,

you can select the Row by using this code,And show the Row with different color. u can highlight,

protected override void Render(System.Web.UI.HtmlTextWriter writer)   
  {         
AddRowSelectToGridView(gridView);        
  base.Render(writer);   
  }      
private void AddRowSelectToGridView(GridView gv)   
  {         
try        
 {            
 foreach (GridViewRow row in gv.Rows)            
 {             
row.Attributes["onmouseover"] = "this.style.cursor='hand';
this.style.textDecoration='underline';";                
row.Attributes["onmouseout"] = "this.style.textDecoration='none';";                 
row.Attributes.Add("onclick",Page.ClientScript.GetPostBackEventReference(gv,"Select$"+row.RowIndex.ToString(), true));           
  }         
}         
catch (Exception ex)         
{         }     
 }

这篇关于我怎样才能识别GridView中编辑一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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