如何为在gridview的rowEdit事件中创建的文本框提供动态ID [英] how to give dynamic id to textboxes created in rowEdit event of gridview

查看:52
本文介绍了如何为在gridview的rowEdit事件中创建的文本框提供动态ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码



This is my code

protected void newgrid_edit(GridViewEditEventArgs e, object sender)
       {
           hitechLatestEntities database = new hitechLatestEntities();
           ((GridView)sender).EditIndex = e.NewEditIndex;

           ((GridView)sender).DataSource = database.SUB_HEAD;
           ((GridView)sender).DataBind();

       }





SUB_HEAD表有两个属性,命名为sub_head_code和详情。执行e.NewEditIndex时,行更改为文本框。我想为这些文本框提供ID以便在更新事件中获取。请记住,我正在注意aspx文件。一切都在代码背后。



SUB_HEAD table has two attributes naming sub_head_code and particulars. when e.NewEditIndex is executed, row changes to textboxes. i want to give IDs to those textboxes for fetching in update event. Please keep in mind, i am doing noting in aspx file. Everything is in code behind.

推荐答案

protected void newgrid_edit(GridViewEditEventArgs e, object sender) 
{
     GridViewRow selectRow = grd.Rows(e.NewEditIndex);
     TextBox txtSomeId=(TextBox)selectRow.Cells[3].FindControl("txtSome"); 
}





txtSomeId是此处的ID。



txtSomeId is the Id here.


这篇关于如何为在gridview的rowEdit事件中创建的文本框提供动态ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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