Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to add command argument in linkbutton, which display the record from codebehind:

XML
<asp:LinkButton ID="lnkPrev" Visible="false" runat="server" Text="Prev" OnClick="lnkPage_Click"
               CommandArgument="<%# Container.DataItem %>"><img src="../images/previousBtn.gif" border="0"/></asp:LinkButton></div>


i want it to display commandargument out of datalist or itemtemplate..
if i put it headertemplate than("%#Conntainer.DataItem %#") is not work.
so what the alternative
Posted

Try

<%# ((DataRowView)Container.DataItem)["FieldName"] %>


or

<%#DataBinder.Eval(Container.DataItem, "FieldName")%>



Please vote and Accept Answer if it Helped.
 
Share this answer
 
v3
Try this,
CommandArgument='<%# Eval("fieldname") %>'
 
Share this answer
 
Comments
balongi 16-Dec-10 8:51am    
In code behind the value is come from this code:
if ((LinkButton)sender == lnkNext)
{
lnkPrev.CommandArgument = (PageIndex + 1).ToString();
lnkNext.CommandArgument = ((PageIndex + 1) + DisplayPage).ToString();
}
balongi 16-Dec-10 8:51am    
here lnkprev.commandargument, give value that i reterive in container.data item.. now how i reterive it in eval. please tell

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900