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:
00904387
Views:
23
I think I may be brain dead today. I tried the second option, but could not get it to work. I think I am doing something wrong. I am going to shorten the example a bit to make it easier. When I put this in:
NavigateURL='CompanyData.aspx?CompanyID=
<%# DataBinder.Eval(Container.DataItem, "CompanyID") %>'   
The program runs, but the link that is generated is:
http://localhost/StockIndex/CompanyData.aspx?CompanyID=<% #DataBinder.Eval(Containter, "DataItem.SICCode") %>
So it seems that if anything other than <%# DataBinder.Eval(param, param) %> is between the quotes, the expression is not evaluated.


>>>>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