Question

I am new to this:

In Visual Studio 2010, asp.net

Webpage A has a gridview with a column of hyperlink of companyid:

<asp:TemplateField HeaderText="Company" ItemStyle-Width="20%" >
     <ItemTemplate>
         <asp:HyperLink Text='<%# (Eval("Company"))%>' ID="HyperLink1" 
                       Target="_blank" runat="server"  
                        NavigateUrl= WHAT SHOULD I PUT HERE TO NAVIGATE TO PAGE B WHICH IS ALSO IN THE SOLUTION
     </ItemTemplate>
</asp:TemplateField>

I want to navigate to another page that's also in the solution file, but I don't know what address to use as it's not some links that's hosted already like "google.ca"

For the new webpage, I don't want any buttons or like that, I just want a page to show the details of a company, using "select * from table where companyid= 'value_from_pageA_hyperlink'. How can I build the page so that it's url could be something like www.somepage/key=?" Or can I set up a global value so that I can pass the companyid in the hyperlink to the other page?

I have been crazed by those.

Was it helpful?

Solution 2

You Can Send A Query String And Get it Through request.params

 <asp:HyperLink Text='<%# (Eval("Company"))%>' ID="HyperLink1" 
                   Target="_blank" runat="server"  
                    NavigateUrl="page2.aspx?variablename=value"/>

and get it through

request.params["variablename"]

on another page I think it Should work

OTHER TIPS

Use

<asp:HyperLink Text='<%# (Eval("Company"))%>' ID="HyperLink1" Target="_blank" runat="server" 
NavigateUrl='~/PageB.aspx?companyId=<%# Eval("CompanyID")%>'/>

"~/" in an ASP.NET URL means that the address is relative to the current application.

http://msdn.microsoft.com/en-us/library/6c3yckfw(v=vs.100).aspx

<asp:TemplateField HeaderText="Company" ItemStyle-Width="20%" >
                        <ItemTemplate>
                            <asp:HyperLink Text='<%# (Eval("Company"))%>' ID="HyperLink1" Target="_blank" runat="server" 
                            NavigateUrl='<%# GetCompanyUrl(Eval("Company"))%>'/>
                        </ItemTemplate>
                    </asp:TemplateField>

protected string GetCompanyUrl (object companyNum)
    {
        return "./NewPageName.aspx?companyId=" + companyNum.ToString(); 
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top