Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A Gridview with hyperlink is present

The HYPERLINK contains:
ASP.NET
<asp:HyperLinkField runat="server" NavigateUrl='<%#state.aspx?id="+DataBinder.Eval(Container.DataItem,"Category_name")+"&d="+DataBinder.Eval
(Container.DataItem,"Subcategory_name"%>' Text='<%#Eval("Category_name") %>' />


Category_name and Subcategory_name:These are the columns in database table.

Error Occured:
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.HyperLinkField does not have a DataBinding event.


How to solve this?


Thank's,
Sravya
Posted
Updated 2-Jun-13 19:49pm
v2

Intead of asp:HyperLinkField try using asp:TemplateField[^].
Try this:
ASP.NET
<asp:TemplateField>
    <ItemTemplete>
        <asp:HyperLink runat="server" NavigateUrl='<%#state.aspx?id="+DataBinder.Eval(Container.DataItem,"Category_name")+"&d="+DataBinder.Eval
(Container.DataItem,"Subcategory_name"%>' Text='<%#Eval("Category_name") %>' />
    </ItemTemplete>
</asp:TemplateField>



--Amit
 
Share this answer
 
v2
Comments
Thanks7872 3-Jun-13 2:15am    
seems good one...↑voted..!
_Amy 3-Jun-13 2:17am    
Thanks Rohan. :)
Include the following namespace in your c# page
System.Web.UI


Refer the following link
how to add Hyperlink in gridview in ASP.NET[^]
 
Share this answer
 
Hi,

try like below.

ASP.NET
<asp:hyperlinkfield runat="server" navigateurl='<%=String.Format("state.aspx?ID={0}&d={1}", Eval("Category_Name"), Eval("Subcategory_name") %>' Text='<%#Eval("Category_name") %>' />


refer this[^]

hope it works.
 
Share this answer
 
v4

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