DataList ItemCommand - trying to get data from contained control

X

Xavier Pacheco

Can anyone make heads or tails out of this? I have a DataList control
that contains a DropDownList and a HyperLink control. The HyperLink
control initiates a command named "REGISTER".

The following code executes, I find the DropDownList, but it contains
no values. IOW, it appears to be empty.

Am I going about this correctly? When the user presses the hyperlink
contained in the ItemTemplate of the DataList, I want to get the
selected value of the DropDownList, also contained in the Item Template
of the DataList.

private void DataList1_ItemCommand(object source,
system.Web.UI.WebControls.DataListCommandEventArgs e)
{
if ( e.CommandName == "REGISTER" )
{
string ctl_name = String.Format( CTRLNAME, e.Item.ItemIndex );
DropDownList ddl = (DropDownList)e.Item.FindControl(
"DropDownList1" );
int EventInstanceID = Int32.Parse( ddl.SelectedValue );
}
}

Any ideas ?
- x
 
N

Nathan Sokalski

It looks like you are accessing the control correctly, but before I try to
solve your problem any further, might I point out that you are assigning
values from that control to variables, but then the eventhandler is done. In
otherwords, can I ask how you are determining whether or not you actually
got the data from the control?
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top