Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DataList ItemCommand - trying to get data from contained control

Reply
Thread Tools

DataList ItemCommand - trying to get data from contained control

 
 
Xavier Pacheco
Guest
Posts: n/a
 
      08-24-2005
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
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      08-27-2005
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?
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

"Xavier Pacheco" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataList in a composite control. ItemCommand not firing. shantanu_kush@hotmail.com ASP .Net 1 07-24-2006 09:58 AM
Custom Server Control with DataList and ItemCommand not firing Ryan Shaw ASP .Net Building Controls 1 06-01-2005 09:07 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Re: Datalist itemcommand not working via usercontrol Marina ASP .Net 3 02-29-2004 05:14 PM
Itemcommand and Datalist problem Kenneth ASP .Net 3 01-05-2004 04:49 AM



Advertisments