-
Help: append two data fileds in HyperLink string
The following line can product this link: summary.aspx?ID=123
<asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='<%#
"summary.aspx?ID=" & DataBinder.Eval(Container.DataItem,"ID")%>'>
I need to use a second value form the data field called SID to produce a
link like:
summary?ID=123&SID=456 (SID=456)
How?
-
Re: Help: append two data fileds in HyperLink string
You are on the right track. Take your aspx name and move it out of the DataBinder
statement and add a second DataBinder for the "SID".
<asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='summary.aspx?ID=<%#
DataBinder.Eval(Container.DataItem,"ID")%>&SID=<%# DataBinder.Eval(Container.DataItem,"SID")%>'>
Just in case your interested...
Many of the people I work with miss exactly what is going on here when they
first start working with the DataBinder.Eval. They don't realize that all
that's going on here is that the DataBinder.Eval is simply converting returning
the text corrsponding to the value of the field in your dataset. You can
actually do this for a number of the controls attributes. I use it quite
often in the visible proptery for the hyperlink controls.
If your new to working with DataBinder.Eval then here is a quick bit of info
you may find useful as you continue working with these controls.
The really cool thing about this is that you can actually call functions
to handle things like formatting. Here is a simple function call...
<%# FormatMyData(DataBinder.Eval(Container.DataItem,"SID"))%>
Here is a sample that can turn the hyperlink off and on as needed.
<asp:Label Visible='<%# DataBinder.Eval(Container,"DataItem.Visible") %>'
Runat=server>
Or a more realistic sample... if the ID number ends in a 00 then we want
the lable to be displayed, else we want it to be turned off.
<asp:Label Visible='<%#IIF(Right(DataBinder.Eval(Container,"DataItem.ID"),
2) = "00", "False", "True") %>' Runat=server>
I missed this for the first 4 months or so that I was working with these
controls.
Best Regards,
Greg Rothlander
Austin/400
grothlander@austin400.com
"milo" <milo001@hotmail.com> wrote:
>
>The following line can product this link: summary.aspx?ID=123
>
><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='<%#
>"summary.aspx?ID=" & DataBinder.Eval(Container.DataItem,"ID")%>'>
>
>I need to use a second value form the data field called SID to produce a
>link like:
>summary?ID=123&SID=456 (SID=456)
>
>How?
>
-
Re: Help: append two data fileds in HyperLink string
Thanks, but it still does not work although no syntax error. The whole string
(<%#...) becomes the query string instead of ID/SID numbers.
The hypelink is within a DataList. Does this make difference?
"Greg Rothlander" <grothlander@austin400.com> wrote:
>
>
>You are on the right track. Take your aspx name and move it out of the
DataBinder
>statement and add a second DataBinder for the "SID".
>
><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='summary.aspx?ID=<%#
>DataBinder.Eval(Container.DataItem,"ID")%>&SID=<%# DataBinder.Eval(Container.DataItem,"SID")%>'>
>
>Just in case your interested...
>
>Many of the people I work with miss exactly what is going on here when they
>first start working with the DataBinder.Eval. They don't realize that all
>that's going on here is that the DataBinder.Eval is simply converting returning
>the text corrsponding to the value of the field in your dataset. You can
>actually do this for a number of the controls attributes. I use it quite
>often in the visible proptery for the hyperlink controls.
>
>If your new to working with DataBinder.Eval then here is a quick bit of
info
>you may find useful as you continue working with these controls.
>
>The really cool thing about this is that you can actually call functions
>to handle things like formatting. Here is a simple function call...
>
><%# FormatMyData(DataBinder.Eval(Container.DataItem,"SID"))%>
>
>Here is a sample that can turn the hyperlink off and on as needed.
>
><asp:Label Visible='<%# DataBinder.Eval(Container,"DataItem.Visible") %>'
>Runat=server>
>
>Or a more realistic sample... if the ID number ends in a 00 then we want
>the lable to be displayed, else we want it to be turned off.
><asp:Label Visible='<%#IIF(Right(DataBinder.Eval(Container,"DataItem.ID"),
>2) = "00", "False", "True") %>' Runat=server>
>I missed this for the first 4 months or so that I was working with these
>controls.
>
>Best Regards,
>
>Greg Rothlander
>Austin/400
>grothlander@austin400.com
>
>
>"milo" <milo001@hotmail.com> wrote:
>>
>>The following line can product this link: summary.aspx?ID=123
>>
>><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='<%#
>>"summary.aspx?ID=" & DataBinder.Eval(Container.DataItem,"ID")%>'>
>>
>>I need to use a second value form the data field called SID to produce
a
>>link like:
>>summary?ID=123&SID=456 (SID=456)
>>
>>How?
>>
>
-
Re: Help: append two data fileds in HyperLink string
Was your original version doing this or did this just start after I gave you
the sample below?
If your orginal one did this, then I need the rest of the ASPX and and a
sample of your XML to see what is wrong. If it just started when you add
the code I gave you, send me the new page and XML and I can fix it for you.
When an error like that occurs... something is wrong with the syntax of the
attribute itself.
Let me know if this was happening before you used the code I sent you.
"milo" <milo001@hotmail.com> wrote:
>
>Thanks, but it still does not work although no syntax error. The whole string
>(<%#...) becomes the query string instead of ID/SID numbers.
>
>The hypelink is within a DataList. Does this make difference?
>
>
>
>"Greg Rothlander" <grothlander@austin400.com> wrote:
>>
>>
>>You are on the right track. Take your aspx name and move it out of the
>DataBinder
>>statement and add a second DataBinder for the "SID".
>>
>><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='summary.aspx?ID=<%#
>>DataBinder.Eval(Container.DataItem,"ID")%>&SID=<%# DataBinder.Eval(Container.DataItem,"SID")%>'>
>>
>>Just in case your interested...
>>
>>Many of the people I work with miss exactly what is going on here when
they
>>first start working with the DataBinder.Eval. They don't realize that
all
>>that's going on here is that the DataBinder.Eval is simply converting
returning
>>the text corrsponding to the value of the field in your dataset. You can
>>actually do this for a number of the controls attributes. I use it quite
>>often in the visible proptery for the hyperlink controls.
>>
>>If your new to working with DataBinder.Eval then here is a quick bit of
>info
>>you may find useful as you continue working with these controls.
>>
>>The really cool thing about this is that you can actually call functions
>>to handle things like formatting. Here is a simple function call...
>>
>><%# FormatMyData(DataBinder.Eval(Container.DataItem,"SID"))%>
>>
>>Here is a sample that can turn the hyperlink off and on as needed.
>>
>><asp:Label Visible='<%# DataBinder.Eval(Container,"DataItem.Visible") %>'
>>Runat=server>
>>
>>Or a more realistic sample... if the ID number ends in a 00 then we want
>>the lable to be displayed, else we want it to be turned off.
>><asp:Label Visible='<%#IIF(Right(DataBinder.Eval(Container,"DataItem.ID"),
>>2) = "00", "False", "True") %>' Runat=server>
>>I missed this for the first 4 months or so that I was working with these
>>controls.
>>
>>Best Regards,
>>
>>Greg Rothlander
>>Austin/400
>>grothlander@austin400.com
>>
>>
>>"milo" <milo001@hotmail.com> wrote:
>>>
>>>The following line can product this link: summary.aspx?ID=123
>>>
>>><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='<%#
>>>"summary.aspx?ID=" & DataBinder.Eval(Container.DataItem,"ID")%>'>
>>>
>>>I need to use a second value form the data field called SID to produce
>a
>>>link like:
>>>summary?ID=123&SID=456 (SID=456)
>>>
>>>How?
>>>
>>
>
-
Re: Help: append two data fileds in HyperLink string
Hello,
My original code works fine for one parameter i.e. summary.aspx?ID=123 but
I could not make it work by adding 2nd parameter. When I tried your code,
it did not work at all, even just one parameter. It sinply show the whole
line of code as parameter.
"Greg Rothlander" <grothlander@austin400.com> wrote:
>
>Was your original version doing this or did this just start after I gave
you
>the sample below?
>
>If your orginal one did this, then I need the rest of the ASPX and and a
>sample of your XML to see what is wrong. If it just started when you add
>the code I gave you, send me the new page and XML and I can fix it for you.
>
>
>When an error like that occurs... something is wrong with the syntax of
the
>attribute itself.
>
>Let me know if this was happening before you used the code I sent you.
>
>"milo" <milo001@hotmail.com> wrote:
>>
>>Thanks, but it still does not work although no syntax error. The whole
string
>>(<%#...) becomes the query string instead of ID/SID numbers.
>>
>>The hypelink is within a DataList. Does this make difference?
>>
>>
>>
>>"Greg Rothlander" <grothlander@austin400.com> wrote:
>>>
>>>
>>>You are on the right track. Take your aspx name and move it out of the
>>DataBinder
>>>statement and add a second DataBinder for the "SID".
>>>
>>><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='summary.aspx?ID=<%#
>>>DataBinder.Eval(Container.DataItem,"ID")%>&SID=<%# DataBinder.Eval(Container.DataItem,"SID")%>'>
>>>
>>>Just in case your interested...
>>>
>>>Many of the people I work with miss exactly what is going on here when
>they
>>>first start working with the DataBinder.Eval. They don't realize that
>all
>>>that's going on here is that the DataBinder.Eval is simply converting
>returning
>>>the text corrsponding to the value of the field in your dataset. You
can
>>>actually do this for a number of the controls attributes. I use it quite
>>>often in the visible proptery for the hyperlink controls.
>>>
>>>If your new to working with DataBinder.Eval then here is a quick bit of
>>info
>>>you may find useful as you continue working with these controls.
>>>
>>>The really cool thing about this is that you can actually call functions
>>>to handle things like formatting. Here is a simple function call...
>>>
>>><%# FormatMyData(DataBinder.Eval(Container.DataItem,"SID"))%>
>>>
>>>Here is a sample that can turn the hyperlink off and on as needed.
>>>
>>><asp:Label Visible='<%# DataBinder.Eval(Container,"DataItem.Visible")
%>'
>>>Runat=server>
>>>
>>>Or a more realistic sample... if the ID number ends in a 00 then we want
>>>the lable to be displayed, else we want it to be turned off.
>>><asp:Label Visible='<%#IIF(Right(DataBinder.Eval(Container,"DataItem.ID"),
>>>2) = "00", "False", "True") %>' Runat=server>
>>>I missed this for the first 4 months or so that I was working with these
>>>controls.
>>>
>>>Best Regards,
>>>
>>>Greg Rothlander
>>>Austin/400
>>>grothlander@austin400.com
>>>
>>>
>>>"milo" <milo001@hotmail.com> wrote:
>>>>
>>>>The following line can product this link: summary.aspx?ID=123
>>>>
>>>><asp:HyperLink id=lnkSummary runat="server" Text="Summary" NavigateUrl='<%#
>>>>"summary.aspx?ID=" & DataBinder.Eval(Container.DataItem,"ID")%>'>
>>>>
>>>>I need to use a second value form the data field called SID to produce
>>a
>>>>link like:
>>>>summary?ID=123&SID=456 (SID=456)
>>>>
>>>>How?
>>>>
>>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks