0

I am trying to pass an Id from aspx to .cs. This is the code i have in the aspx:

 <asp:Button ID="btnAddAsFriend" runat="server" Text="Add as Friend" onclick="btnAddAsFriend_Click" CommandName = "Id" CommandArgument='<%# Eval("u.UserID.ToString()") %>'/>

The CommandArgument is being set but when i try to read it from the .cs its getting null. This is the code I have in the .cs

 protected void btnAddAsFriend_Click(object sender, EventArgs e)
        {
            string id = ((Button)sender).CommandArgument;

        }

Thanks

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133

0 Answers0