Hyperlink

Hyperlink

Post by Juli » Sun, 19 Jan 2003 07:32:54



Can someone tell me what is wrong with this hyperlink:

<a href="admin1.aspx?ItemID=<%# ds1.FieldValue("ItemID", Container) %>"></a>

The hyperlink does not even appear in my web page.

Thanks

 
 
 

Hyperlink

Post by Raphael Ilo » Sat, 18 Jan 2003 23:47:56


...I presume 'ds1' is of the DataSet object type. Is there a method called
FieldValue() in the list of public methods for the DataSet object? I don't
really know for certain but I'm somewhat doubtful.

...well let's assume there is, what you are basically doing is called 'late
data binding' and it's evaluated only when you call the DataBind() method of
the applicable container.

If you've written this code stub as part of codes within a data list object
(DataGrid, DataList, Repeater, etc.) and you've called the DataBind() of the
data list object (as well as specify a value for the datasource property, of
course) then this code should work. However, if the case were different then
you'd need to call the DataBind() of the Page object.

Regards, Raphael (www.ilohraphael.net)


Quote:> Can someone tell me what is wrong with this hyperlink:

> <a href="admin1.aspx?ItemID=<%# ds1.FieldValue("ItemID", Container)
%>"></a>

> The hyperlink does not even appear in my web page.

> Thanks


 
 
 

Hyperlink

Post by Allen Zaudtk » Sun, 19 Jan 2003 04:49:48


here is your link
<a href="admin1.aspx?ItemID=<%# ds1.FieldValue("ItemID", Container) %>"></a>

Here is a link with your Url with some text to display as the link on the
page
<a href="admin1.aspx?ItemID=<%# ds1.FieldValue("ItemID", Container) %>">SOME
TEXT</a>

That was what jumped out right away.

If ds1 is a dataset, then you need to access the table within the dataset.
In your scenario, if the link is on the page, ds1 needs to be declared as
public or private at the class level of the page.  I am not sure you want to
do this anyway.

If the link is inside a repeater (like Raphael said, I am not sure about
Datagrids et al) but the syntax would be

<a href="admin1.aspx?ItemID=<%# DataBinder.Eval(Container.DataItem,
"ItemID")%>">SOME TEXT</a>

Where the repeater is bound to any data source that is Enumerable.  Context
code from the page and/or the code behind would be more helpful.

Al Zaudtke


Quote:> Can someone tell me what is wrong with this hyperlink:

> <a href="admin1.aspx?ItemID=<%# ds1.FieldValue("ItemID", Container)
%>"></a>

> The hyperlink does not even appear in my web page.

> Thanks