473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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!
Nov 17 '05 #1
4 943
Jos
"Arjen" <bo*****@hotmail.com> wrote in message
news:bg**********@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
Nov 17 '05 #2

"Jos" <jo***************@fastmail.fm> schreef in bericht
news:#J**************@TK2MSFTNGP11.phx.gbl...
"Arjen" <bo*****@hotmail.com> wrote in message
news:bg**********@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!
Nov 17 '05 #3
Jos
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
Nov 17 '05 #4

"Jos" <jo***************@fastmail.fm> schreef in bericht
news:ON**************@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!


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Carl Howarth | last post by:
Hi, I have a check box list within a datalist. Can anybody tell me how I go about accessing the onclick event of these checkbox lists? (using vb.net) Many thanks, Carl Howarth...
0
by: Arjen | last post by:
Hello, Here is my datalist. <asp:DataList id="myDataList" CellPadding="4" Width="100%" runat="server"> <ItemTemplate> <span class="Normal"> <asp:HyperLink id="link" Text='<%#...
1
by: Arjen | last post by:
Hello, Does somebody haves a solution for this? Thanks! Line 74: if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
3
by: Kyong Kwak | last post by:
Hey all my second post! wanted to know if I can cache an entire control.. this is what I have.. Webform has header, nav, footer, and Usercontrol_1. Usercontrol_1 has a datalist and paging...
2
by: Patrick.O.Ige | last post by:
Is it possible to bind a checkboxlist if this checkboxlist is in a datalist Bcos when i add a CheckBoxlist to a Datalist i get :- Object reference not set to an instance of an object error at:-...
2
by: Andrew | last post by:
Hi, How do I access the cells of a table that is located in a datalist control ? I have the datalist control and some asp controls in it up n it is working fine. My datalist is bound to a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.