Home About Us SQL Interview Book Contact Us RSS
Articles
Tools
Code Snippets
Links
Tips & Tricks
FAQ
Resources
Articles
Code Snippets
Links
FAQ
Resources

Saravana Kumar
Vinod Kumar


Passing Multiple Parameters in NavigateURL Property of Hyperlink 

One of the frequently asked questions in newsgroups is, how do I pass multiple parameters in the hyperlinkcolumn of a datagrid. If you need to pass multiple parameters then convert that column to itemtemplate hyperlink column and then pass multiple parameters using navigateURL property. Consider an example in which you need to pass two parameters to Navigate URL,

 <asp:datagrid id="Datagrid3" runat="server" AutoGenerateColumns="False" BorderColor="black" 
       HeaderStyle-CssClass="tableHeader" ItemStyle-CssClass= "tableItem">
        <Columns>
                  <asp:TemplateColumn HeaderText="Order">
                      <ItemTemplate>
                         <asp:Hyperlink runat= "server" Text='<%# DataBinder.Eval(Container.DataItem,"ProductName").tostring%>' 
                          NavigateUrl='<%# "page.aspx?Name=" & DataBinder.Eval (Container.DataItem,"ProductName").tostring & _  
                          "&ProductID=" & DataBinder.Eval(Container.DataItem,"ProductID").tostring %>' ID="ProductName"/>  
  
                      </ItemTemplate>
                     </asp:TemplateColumn>                                    
         </Columns>
</asp:datagrid>

This is how you can pass two paramaters to NavigateURL property of Hyperlink column in DataGrid.