Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Hyperlink in a DataGrid
Message
 
To
15/05/2004 14:25:40
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00904258
Message ID:
00904437
Views:
14
Keith and Danny,

Thank you for your help. I finally got it to work. It's amazing what a good nights sleep does for the human brain. I used a template column and this was the string for NavigateURL:
NavigateURL='<%# "CompanyData.aspx?CompanyID=" + DataBinder.Eval(Container, "DataItem.CompanyID") + "&IndexTypeID=" + DataBinder.Eval(Container, "DataItem.IndexTypeID") %>'
I think if you are doing this in VB.NET, you substitute an & for the +.

>>>>I am having a problem implementing a HyperLink in a ASP.NET DataGrid where there are not one but two URL Fields that I need. Rather than this:
>>>>
>>>>
>>>>URL field: CompanyID
>>>>URL format string: CompanyData.aspx?CompanyID={0)
>>>>
>>>>
>>>>I need something like:
>>>>
>>>>
>>>>URL field: CompanyID, IndexTypeID
>>>>URL format string: CompanyData.aspx?CompanyID={0)&IndexTypeID={1}
>>>>
>>>>
>>>>Any ideas?
>>>
>>>Not sure what the question is here. Are you looking for code for your DataGrid? Do you already have code for the first example and need it expanded to include the second example?
>>
>>Sorry that I wasn't clearer. The first example I posted works fine. I put the HyperLink into the web DataGrid and I am able to set the properties so that the link is generated dynamically. This is how I setup the HyperLink in DataGrid with the VS.NET 2003 property builder:
>>
>>
>>URL field: CompanyID
>>URL format string: CompanyData.aspx?CompanyID={0}
>>
>>
>>However, when I want to pass two variables in the URL format string, CompanyID and IndexTypeID, I can't get it to work. I am trying to dynamically link to the CompanyData.aspx page, but pass 2 variables in the query string. Does that make sense?
>>
>
>Sorry, I never used the DataGrid Builder to make hyperlinks, but now I understand the question.
>
>The answer is that the Builder isn't smart enough to handle two URL fields. You have some options to set up the DataGrid the way you want it:
>
>1. Create a computed column in the DataSet (or manually add a field to the DataReader or IList object if you aren't using a DataSet) that contains the entire QueryString.
>
MyDataSet.Tables(0).Columns.Add("Link", _
>Type.GetType("System.String"), "'CompanyID=' + Convert
>(CompanyID,'System.String') + '&IndexTypeID=' + Convert
>(IndexTypeID,'System.String'))
>
>
>Use this computed column in the URL field of the Builder.
>
>- or -
>
>2. Convert the Hyperlink column to a template column and insert the CompanyID and IndexTypeID into the QueryString in the HTML of the page.
>
 ... NavigateURL="CompanyData.aspx?CompanyID=
><%# DataBinder.Eval(Container.DataItem, "CompanyID")   
>&IndexTypeID=<%# DataBinder.Eval(Container.DataItem, "IndexTypeID")"
>(Change < back to the "less-than" character in your code)
>
>3. There are other ways of doing this that are more complex. If neither of the first two are what you want, we can work on a different way.
Chris McCandless
Red Sky Software
Previous
Reply
Map
View

Click here to load this message in the networking platform