Jes Sie

Jes Sie

  • 708
  • 1.2k
  • 264.2k

Passing 2 parameters in the command argument in a Gridview

Aug 21 2018 2:12 AM
Can anyone teach me how to pass the 2nd parameter in the command argument in c#? I tried the code below but it only passes the 1st parameter to the 2 command argument.
  1. protected void gvLessonPlan_RowCommand(object sender, GridViewCommandEventArgs e)  
  2.         {  
  3.             string id = lblDeledtedId.Text;  
  4.             
  5.             if(e.CommandName == "DeleteRow")  
  6.             {  
  7.                 LessonPlanDataAccess.DeleteLessonPlan(Convert.ToString(e.CommandArgument), Convert.ToString(e.CommandArgument));  
  8.   
  9.                 int user = Convert.ToInt32(lblID.Text);  
  10.                 string activity = "deleted lesson plan entry with id " + id;  
  11.                 SIBSAdminDataAccess.InsertAuditTrail(activity, user);  
  12.   
  13.                 getLessonPlan();  
  14.             }  
  15.         }  
  16.   
  17.         protected void LinkButton1_Click(object sender, EventArgs e)  
  18.         {  
  19.             GridViewRow row = (GridViewRow)((LinkButton)sender).NamingContainer;  
  20.             Label lblId = row.FindControl("lblId"as Label;  
  21.             Label COHeaderId = row.FindControl("lblCOHeaderId"as Label;  
  22.   
  23.             lblDeledtedId.Text = lblId.Text;  
  24.             lblDeletedCoHeader.Text = COHeaderId.Text;  
  25.         }  
 Below is my mark-up
  1. <Columns>  
  2.                                                     <asp:TemplateField HeaderText="Lesson Plan Id" SortExpression="LPId">  
  3.                                                         <EditItemTemplate>  
  4.                                                             <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("LPId") %>'></asp:TextBox>  
  5.                                                         </EditItemTemplate>  
  6.                                                         <ItemTemplate>  
  7.                                                             <asp:Label ID="lblId" runat="server" Text='<%# Bind("LPId") %>'></asp:Label>  
  8.                                                         </ItemTemplate>  
  9.                                                     </asp:TemplateField>  
  10.                                                     <asp:BoundField DataField="GLCode" HeaderText="Grade Level" SortExpression="GLCode" />  
  11.                                                     <asp:BoundField DataField="SubCode" HeaderText="Subject" SortExpression="SubCode" />  
  12.                                                     <asp:BoundField DataField="WeekNo" HeaderText="WeekNo" SortExpression="WeekNo" />  
  13.                                                     <asp:BoundField DataField="InclusiveDate" HeaderText="InclusiveDate" SortExpression="InclusiveDate" />  
  14.                                                     <asp:BoundField DataField="FullName" HeaderText="FullName" SortExpression="FullName" />  
  15.                                                     <asp:TemplateField HeaderText="COHeaderId" SortExpression="COHeaderId">  
  16.                                                         <EditItemTemplate>  
  17.                                                             <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("COHeaderId") %>'></asp:TextBox>  
  18.                                                         </EditItemTemplate>  
  19.                                                         <ItemTemplate>  
  20.                                                             <asp:Label ID="lblCOHeaderId" runat="server" Text='<%# Bind("COHeaderId") %>'></asp:Label>  
  21.                                                         </ItemTemplate>  
  22.                                                     </asp:TemplateField>  
  23.                                                     <asp:TemplateField HeaderText="Is Lectured" SortExpression="IsLectured">  
  24.   
  25.                                                         <ItemTemplate>  
  26.                                                              <span onclick="return confirm('Are you sure you want to delete? This cannot be undone.')">   
  27.                                                             <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("LPId") %>' CommandName="DeleteRow" CssClass="btn btn-danger" OnClick="LinkButton1_Click">Delete</asp:LinkButton>  
  28.                                                         </span>  
  29.                                                         </ItemTemplate>  
  30.                                                     </asp:TemplateField>  
  31.                                                 </Columns>  
Thanks in advance. 

Answers (1)