在项目模板中包含两个按钮的gridview [英] gridview containing two buttons in item template
本文介绍了在项目模板中包含两个按钮的gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.. !!
我有一个数据网格,其中前两列是包含按钮的项目模板.
我有一个row_command事件,在其中检查
的命令名称属性
特定按钮.
我想检查选中了哪个行按钮
我使用了以下代码.
但它不起作用.
Hello Everyone..!!
I have a data grid in which first two columns are item templates containing buttons.
I have a row_command event where i check the command name property of
particular button.
i want to check which row button is checked
i have used the following code.
but it is not working.
if (e.CommandName=="rate")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gr = grdOTIF.Rows[index];
}
请帮助我.
Kindly help me with the same.
推荐答案
试试这个:
HTML:(在gridview的项目模板中)
Hi,
Try this:
HTML:(In the item template of your gridview)
<asp:linkbutton id="lnkEdit" runat="server" text="Edit" commandname="Edit"/>
<asp:linkbutton id="lnkEdit" runat="server" text="Edit" commandname="Delete"/>
后面的代码:
Code Behind:
if (e.CommandName=="Edit")
{
//do edit operation
}
else if (e.CommandName=="Delete")
{
//do the deletion
}
--Amit
--Amit
更改如下:
Change as Below :
<asp:linkbutton id="lnkEdit" runat="server"text="Edit" commandname="Edit"/>
<asp:linkbutton id="lnkdelete" runat="server" text="Edit" commandname="Delete"/>
Code Behind:
if (e.CommandName.equals("Edit"))
{
int index = System.Convert.ToInt32(e.CommandArgument);
else if(e.commandname.equals("Delete"))
{
int index = System.Convert.ToInt32(e.CommandArgument);
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var LinkButton2 = (Button)e.Row.FindControl("btnrate");
LinkButton2.CommandArgument = e.Row.RowIndex.ToString();
}
}
这篇关于在项目模板中包含两个按钮的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文