DataBinder.Eval usage in Href [modified]
-
I think
runat="server"
is the culprit. Just remove it if you dont need. If you wantrunat="server"
you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it insideItemDataBound
event.Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET<asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="test"> <ItemTemplate> <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a> <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn> <asp:TemplateColumn HeaderText="Invoice No"> <ItemTemplate> <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:datagrid> Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.
-
Sorry i misplaced the code Here is my full code
<asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="test">
<ItemTemplate>
<a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
<asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
<asp:TemplateColumn HeaderText="Invoice No">
<ItemTemplate>
<a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.
-
I think
runat="server"
is the culprit. Just remove it if you dont need. If you wantrunat="server"
you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it insideItemDataBound
event.Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NETAbhishek Sur wrote:
I think runat="server" is the culprit
No, really its not!
Abhishek Sur wrote:
you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.
Why? Thats just 10x more complicated than expressing it as an attribute.
-
Abhishek Sur wrote:
I think runat="server" is the culprit
No, really its not!
Abhishek Sur wrote:
you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.
Why? Thats just 10x more complicated than expressing it as an attribute.
J4amieC wrote:
Why? Thats just 10x more complicated than expressing it as an attribute.
Yes.. Event if it is complicated, but ASP.NET is meant to deal with this events. It is better to handle server controls in the server and client control in the designer. I generally dont mix both in designer. Well, its upon the choice though.. ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET -
J4amieC wrote:
Why? Thats just 10x more complicated than expressing it as an attribute.
Yes.. Event if it is complicated, but ASP.NET is meant to deal with this events. It is better to handle server controls in the server and client control in the designer. I generally dont mix both in designer. Well, its upon the choice though.. ;)
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET -
href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a> Here i havent used the concatenation but i have the problem with the quotation marks.
Seeing as you cant be bothered to read my answer, i cant be bothered to retype it, so i'll jusdt copy/paste from my answer
J4amieC wrote:
<a runat="server" id="h2" href='<%# "frmViewInvoiceDetails.aspx?invoiceID=" + DataBinder.Eval(Container.DataItem, "firstname")%>'> NB: Pay special attention to the usage of single & double quotes in the above example.
-
Seeing as you cant be bothered to read my answer, i cant be bothered to retype it, so i'll jusdt copy/paste from my answer
J4amieC wrote:
<a runat="server" id="h2" href='<%# "frmViewInvoiceDetails.aspx?invoiceID=" + DataBinder.Eval(Container.DataItem, "firstname")%>'> NB: Pay special attention to the usage of single & double quotes in the above example.
-
Ok i understood that but can u plz help me to give proper quotation for the below code href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
-
Abhishek Sur wrote:
It is better to handle server controls in the server and client control in the designer
But the markup is also dealt with by the server:confused:
I know... It is actually parse through the marker during Page Initialization.... But I think those events are meant to handle those, so why do we avoid them and make all those unnecessary adjustments in the Markup. I always like clean html in the designer with Server Controls in place as well.. It is true, that sometimes I need to do those classic ASP style Server tags in designer, but I do like avoiding those. We create Server controls to have better grip of server side (which is the main motive of ASP.NET) which is absent in the Classic ASP where we always need to write Server Tags in between htmls. For instance we can easily write :
<asp:Label runat="server" Id="lbl" Text="<%=this.X %>"></asp:Label>
(infact it will render nothing in the page) but we dont do, rather we use Page_Load and then setlbl.Text = this.X;
Anyways, some like to write more and more Servertags within html, but personally I always like to handle them from codebehind, if it is avoidable. :):thumbsup:Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET