DataList ItemCommand using Placeholder Ctrl

S

Stuart Shay

Hello All:

I have a Datalist where each row has TextBoxes and Dropdowns that are
created dynamically. The code renders correctly and is very similar to this
sample I found

http://www.codeguru.com/csharp/.net/net_asp/controls/article.php/c12495/

void rptFields_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType
!= ListItemType.AlternatingItem)
return;

DataRow dr = ((DataRowView)e.Item.DataItem).Row;
PlaceHolder pl = (PlaceHolder)e.Item.FindControl("plControl");
switch (dr["DataType"].ToString().ToLower())
{
case "string":
TextBox txt = new TextBox();
txt.ID = "txtField" + dr["pkParameterID"].ToString();
pl.Controls.Add(txt);
break;

case "tf":
CheckBox chk = new CheckBox();
chk.ID = "chkField" + dr["pkParameterID"].ToString();
pl.Controls.Add(chk);
break;
}


When I call the DataList ItemCommand Event, I am unable to reference the
dropdown list or textbox by using the FindControl Method even if I hardcode
the ControlId as a test.

How can I get the selected value or text of the control

Any help appreciated

Thanks
Stuart
 

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

Members online

Forum statistics

Threads
473,836
Messages
2,569,750
Members
45,545
Latest member
rapter____0

Latest Threads

Top