开发者

How to send multiple command arguments through command button ?(RowCommand Event)

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, try -

<%# Eval("isActiveYN") + ";" + Eval("employeeid") %>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜