can't place label in datalist

  • Thread starter Thread starter Andy Sutorius
  • Start date Start date
A

Andy Sutorius

Hi,

Are datalists able to have labels inside of the ItemTemplate? Every time I
try to place a label in the Item Template it does not show up in the code
behind/intellisense. FYI the datalist contains items that can be placed in
shopping cart. I want the label to notify the user that the placement of the
item into the shopping was successful.

Thanks,

Andy
 
Hi
You can have pretty much any server controls in the itemtemplate.
Datalist items are created dynamically when the datalist is created, which
is why it's not added to the code behind.

You can use the onitemdatabound event to manipulate the server controls.
for example, you can use
Label mylbl = (Label)e.Item.FindControl("lbl_id");
mylbl.Text = "your text";
 
Good deal. Thank you.

jwkjng said:
Hi
You can have pretty much any server controls in the itemtemplate.
Datalist items are created dynamically when the datalist is created, which
is why it's not added to the code behind.

You can use the onitemdatabound event to manipulate the server controls.
for example, you can use
Label mylbl = (Label)e.Item.FindControl("lbl_id");
mylbl.Text = "your text";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top