Gridview的RowCommand事件中获取RowIndex的方法
2010-11-28 15:57
597 查看
第一种:
GridViewRow currRow = (GridViewRow)((LinkButton)e.CommandSource).Parent.Parent;
currRow.RowIndex取得当前行
currRow.Cells[0].Text.Trim()取得当前行的列值
第二种:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = -1;
GridViewRow row = null;
switch (e.CommandName)
case "Command1": // 模板列
// 对于模板列内的按钮,我们需要显示绑定行索引到按钮的 CommandArgument 属性
// 以获取触发事件的行信息
rowIndex = Convert.ToInt32(e.CommandArgument);
row = GridView1.Rows[rowIndex];
}
GridViewRow currRow = (GridViewRow)((LinkButton)e.CommandSource).Parent.Parent;
currRow.RowIndex取得当前行
currRow.Cells[0].Text.Trim()取得当前行的列值
第二种:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = -1;
GridViewRow row = null;
switch (e.CommandName)
case "Command1": // 模板列
// 对于模板列内的按钮,我们需要显示绑定行索引到按钮的 CommandArgument 属性
// 以获取触发事件的行信息
rowIndex = Convert.ToInt32(e.CommandArgument);
row = GridView1.Rows[rowIndex];
}
相关文章推荐
- [GridView]在 RowCommand事件中,自订的Button 如何取出某一列的索引值(RowIndex)
- 在GridView1_RowCommand事件中,如何取Rowindex
- 如何在GridView的RowCommand事件中获取当前的GridViewRow
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- gridview使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- Gridview Row事件响应方法无法获取其它UpdatePanel中控件数据的解决办法
- ASP.NET DEMO 5:如何在GridView的RowCommand事件中获取当前的GridViewRow
- GRIDVIEW在RowCommand事件中找到当前行index的方法(转载)
- gridview的Rowcommand命令中获取行索引的方法总结
- ASPX页面如何获取ASPxGridView的FocusedRowChanged事件?
- asp.net gridview的Rowcommand命令中获取行索引的方法总结
- [原创]GridView各事件获取处理行索引及该行控件方法
- GridView中RowDataBound事件 获取列值的方法
- ASPX页面如何获取ASPxGridView的FocusedRowChanged事件?
- Asp.net 中 GridView 在 RowDataBound事件中获取 某列值 的方法
- gridview中获取主键的值(GridView1_RowCommand,GridView1_PageIndexChanging,GridView1_RowDeleting.....)
- 使用Container.ItemIndex获取Repeater、Gridview行的序号的简单方法
- 如何在GridView的RowCommand事件中获取当前的GridViewRow