获取GridView中TemplatedField中LinkButton命令的当前行
2010-03-03 13:59
351 查看
在GridView中添加一模板列
编辑该模板列中LinkButton的Command事件。
添加如下代码:
方法二:
直接使用CLICK事件的代码:
编辑该模板列中LinkButton的Command事件。
添加如下代码:
protected void lbtnResetPwd_Command(object sender, CommandEventArgs e) { //获取RowIndex LinkButton lb = (LinkButton)sender; GridViewRow row = (GridViewRow)lb.Parent.Parent; //DataControlFieldCell dcf = (DataControlFieldCell)lb.Parent; //GridViewRow gvr = (GridViewRow)dcf.Parent; //gvUserList.SelectedIndex = gvr.RowIndex; gvUserList.SelectedIndex = row.RowIndex; string initPwd = ConfigurationManager.AppSettings["InitPassword"].ToString(); int passwordformat = Convert.ToInt32(ConfigurationManager.AppSettings["PasswordFormat"].ToString()); string newsalt = CommonUtils.GenerateRandomString(6, StringMode.Mix); string newpassword = CommonUtils.EncryptString(initPwd,passwordformat,newsalt); string username = row.Cells[1].Text; int userid = Convert.ToInt32(row.Cells[0].Text); if (UserBLL.ResetPassword(userid, newpassword, passwordformat, newsalt)) lblUserMsg.Text = "用户"+ username + "的密码已重置!"; else lblUserMsg.Text = "用户" + username + "的密码重置失败!"; }
方法二:
直接使用CLICK事件的代码:
protected void lbtnViewRole_Click(object sender, EventArgs e) { int rowIndex = ((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex; RoleModel role = RoleBLL.GetRoleInfo(Int32.Parse(gvRoleList.Rows[rowIndex].Cells[0].Text)); txtRoleNameEdit.Text = role.RoleName; txtRoleDescEdit.Text = role.RoleDesc; cbIsAuth.Checked = role.IsUser; cbIsSysEdit.Checked = role.IsSystem; }
相关文章推荐
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- 单击Gridview中LinkButton,获取当前行索引及某单元格值
- 单击Gridview中LinkButton,获取当前行索引及某单元格值,进行相关处理
- gridview使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- 单击Gridview中LinkButton,获取当前行索引及某单元格值
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- 获取ListView/GridView当前滚动的距离(高度)
- Gridview中通过某个空间获取当前行的索引
- 获取GridView的TemplateField模版中某列值
- 通过 adb shell dumpsys 命令获取当前应用的 component
- GridView模板里获取LinkButton的值(原)
- 利用ICMP协议的PING命令获取客户端当前网络质量 by徐文棋
- gridview_RowCommand 获取当前行中的控件
- FL2440 通过Socket使开发板作为服务器支持多个客户端连接并与之通信,可通过命令获取当前温度。
- 通过ADB命令获取当前activity
- GridView模板列中的TextBox的ontextchanged事件中获取当前行的某列!(转)
- gridview获取当前行索引的方法
- GridView的RowDataBound事件中获取当前行内容的几种方法
- 利用sender的Parent获取GridView中的当前行(转自Web.网际浪人)