"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, November 12, 2011

Hyperlink with more than one parameter Or Error: Server tag not well Formed with Hyperlink

Hi *.*,
In my first day of .net i found this error the with the help of my senior i resolved it.Then i didn't know why it come so.2day my junior faced same issue i gone through and got why it come :).its all because when binding hyperlink with data not at just data, you have to give entire NavigateUrl the Server control. and also (single quote) and (Double quote) have to be in correct way too...

Code :

<asp:DataGrid ID="DGrid" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateColumn HeaderText="Sample Column">
                        <ItemTemplate>
                            <asp:HyperLink runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "UserName").ToString()%>'
                                NavigateUrl='<%# "page1.aspx?id=" + DataBinder.Eval(Container.DataItem,"Id").ToString() + "&Name=" + DataBinder.Eval(Container.DataItem,"UserName").ToString()%>'
                                ID="Hyperlink1" NAME="Hyperlink1" />
                        </ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>


If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: