Ask a Question related to ASP.NET General, Design and Development.
-
Arjen #1
myDataList_ItemDataBound
Hallo,
I have a hyperlink control inside this datalist.
I want to give these hyperlinks some values inside this function
myDataList_ItemDataBound.
private void myDataList_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e) {
// Some code
}
How can I do that?
Can you give me some sample code?
Thanks!
Arjen Guest
-
Jos #2
Re: myDataList_ItemDataBound
"Arjen" <boah123@hotmail.com> wrote in message
news:bgo8br$39n$1@news3.tilbu1.nb.home.nl...> Hallo,
>
> I have a hyperlink control inside this datalist.
> I want to give these hyperlinks some values inside this function
> myDataList_ItemDataBound.
>
> private void myDataList_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataListItemEventArgs e) {
> // Some code
> }
>
> How can I do that?
> Can you give me some sample code?
>
> Thanks!
Something like this:
HyperLink hl=(HyperLink)e.Item.FindControl("MyHyperLinkID");
hl.Text="my new value";
--
Jos
Jos Guest
-
Arjen #3
Re: myDataList_ItemDataBound
"Jos" <josnospambranders@fastmail.fm> schreef in bericht
news:#JcZ8$0WDHA.1512@TK2MSFTNGP11.phx.gbl...> "Arjen" <boah123@hotmail.com> wrote in message
> news:bgo8br$39n$1@news3.tilbu1.nb.home.nl...>> > Hallo,
> >
> > I have a hyperlink control inside this datalist.
> > I want to give these hyperlinks some values inside this function
> > myDataList_ItemDataBound.
> >
> > private void myDataList_ItemDataBound(object sender,
> > System.Web.UI.WebControls.DataListItemEventArgs e) {
> > // Some code
> > }
> >
> > How can I do that?
> > Can you give me some sample code?
> >
> > Thanks!
>
> Something like this:
> HyperLink hl=(HyperLink)e.Item.FindControl("MyHyperLinkID");
> hl.Text="my new value";
>
> --
>
> Jos
>
>
What I forgot to say is that I want to set the hyperlink control with a
value from the current row.
How can I do that?
Thanks!
Arjen Guest
-
Jos #4
Re: myDataList_ItemDataBound
Arjen wrote:
Put this inside the <ItemTemplate>:> What I forgot to say is that I want to set the hyperlink control with
> a value from the current row.
> How can I do that?
<asp:HyperLink runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"fieldname") %>'></asp:HyperLink>
This will set the Text property of the HyperLink,
but you can set other properties in the same way.
Search for help on DataBinder to find more advanced formatting options.
--
Jos
Jos Guest
-
Arjen #5
Re: myDataList_ItemDataBound
"Jos" <josnospambranders@fastmail.fm> schreef in bericht
news:ONsABV3WDHA.1644@TK2MSFTNGP10.phx.gbl...> Arjen wrote:
>>> > What I forgot to say is that I want to set the hyperlink control with
> > a value from the current row.
> > How can I do that?
> Put this inside the <ItemTemplate>:
>
> <asp:HyperLink runat="server" Text='<%#
> DataBinder.Eval(Container.DataItem,"fieldname") %>'></asp:HyperLink>
>
> This will set the Text property of the HyperLink,
> but you can set other properties in the same way.
>
> Search for help on DataBinder to find more advanced formatting options.
>
> --
>
> Jos
>
>
The problem is a little bit more complex, the data value is an integer that
I have to change to some text.
Example:
intNumber is comming out of the database and strValue must be set inside the
hyperlink control.
if intNumber = 1 then the strValue = "High" else strValue = "Low".
How can I do this inside code behind?
Thanks!
Arjen Guest



Reply With Quote

