如何通过命令按钮发送多个命令参数?(RowCommand事件) [英] How to send multiple command arguments through command button ?(RowCommand Event)
本文介绍了如何通过命令按钮发送多个命令参数?(RowCommand事件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图发送翻过多个命令参数时rowcommand叫做:
I'm Trying to send accross multiple command arguments when a rowcommand is called:
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Button ID="btnAct" runat="server" CausesValidation="False" CommandName="Action"
Text='De-Activate' CommandArgument='<%# Bind("isActiveYN") + ";" + Bind("employeeid") %>' />
<asp:Label ID="lblActivate" runat="server" Text='<%# Bind("isActiveYN") %>' Visible='False'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
如何过当我使用多个参数,仅显示了后半期,在此雇员
。如果我只指定一个参数,它的工作原理罚款。
How ever when I use more than one argument it shows only the latter half, in this the employeeid
.If I specify just a single argument,it works fine.
protected void gvEmp_RowCommand(object sender, GridViewCommandEventArgs e)
{
string changeactive = null;
if (e.CommandName == "Action")
{
//LinkButton lnkPortal = (LinkButton)sender;
string isactivestatus = Convert.ToString(e.CommandArgument);
string[] arg = new string[2];
arg = isactivestatus.Split(';');
//lblTest.Text = isavtivestatus.Text;
string status = Convert.ToString(arg[0]);
int empid = Convert.ToInt32(arg[1]);
if (status.ToUpper() == "Y")
{
lblTest.Text = isactivestatus + " Will Change to N " ;
changeactive = "N";
}
else if (arg[0].ToUpper() == "N")
{
lblTest.Text = isactivestatus + " Will Change to Y " ;
changeactive = "Y";
}
DataSet ds = new DataSet("Employees");
string query = "Update employees set isActiveYN='" + changeactive
+ "' where employeeid=" + empid;
SqlConnection con = new SqlConnection("Password=admin;User ID=admin;Initial Catalog=asptest;Data Source=dbsvr");
SqlDataAdapter da = new SqlDataAdapter(query, con);
da.Fill(ds);
BindGrid();
}
}
请指出犯错误试图调试,但无法衡量什么是错的。
Please point out the mistake.I have tried debugging but couldn't gauge what's wrong.
推荐答案
Pavitar,试试 -
Pavitar, try -
<%# Eval("isActiveYN") + ";" + Eval("employeeid") %>
绑定 - 它是双向的使用绑定到修改后的数据传递到服务器端。 ASP无法从客户端的一个值分开,不止一个服务器属性。
Bind - it's bidirectional binding that use to passing modified data to serverside. ASP cannot separate one value from client to more then one server property.
这篇关于如何通过命令按钮发送多个命令参数?(RowCommand事件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文