0

Page Directory is showing errorl like "New line is constatant" when I try to pass multiple values through command argument in Grid View. If I pass one value through command arguments, there is no error. Why it shows error like this?? My page directory and gridview is mention below

 <%@ Page Title="" Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true" CodeBehind="LeaveApprove.aspx.cs" Inherits="Samples.WebForm133" %>
  </asp:Content>
 <asp:Content ID="Content3" ContentPlaceHolderID="MainContent"  
       runat="server">
 </asp:Content>
 <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">                 
  <form id="form1" runat="server">
  <td align="center">
 <asp:GridView ID="gvemployee" runat="server" BorderWidth="1px" 
  CellPadding="3" CellSpacing="2" onrowcommand="gvemployee_RowCommand"                                                                     
 <Columns>
 <asp:TemplateField>
 <ItemTemplate>
 <asp:LinkButton ID="LinkButton1" runat="server"                                           
  CommandArgument='<%#Eval("EmpCode")+","+ Eval("Fromdate",,"+  
  Eval("Todate")%>'>Approve</asp:LinkButton>
  </ItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField>
  <ItemTemplate>
  <asp:LinkButton ID="LinkButton4" runat="server"                                        
  CommandArgument='<%#Eval("EmpCode")+","+ Eval("Fromdate",,"+    
  Eval("Todate")%>'>Reject</asp:LinkButton>
   </ItemTemplate>
   </asp:TemplateField>
   </Columns>
   </asp:GridView>
   </td>
   </tr>
  </asp:Content>

Is there any other method to pass multiple arguments in gridview ?

2
  • you can do this two ways:-1.create a property combining these columns value & then write that property in the command argument.2. use Stirng,Format("{0},{1}",<%#Eval("EmpCode")%>,<%#Eval("Todate")%>). Commented Feb 10, 2015 at 5:43
  • Use Gridview Datakeys property. Commented Feb 10, 2015 at 7:29

1 Answer 1

1

Please write the above line as seen below:

CommandArgument='<%#Eval("EmpCode")+","+ Eval("Fromdate") + "," + Eval("Todate")%>'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.