Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Accessing Drop Down List From a Datagrid


Message #1 by "Hugh McLaughlin" <hugh@k...> on Thu, 20 Feb 2003 21:00:50
Hello everyone and thanks for your help in advance.  I am working on an 
application that requires the use of two drop down lists embedded within 
a datagrid.  There will also be a submit button for each record in the 
grid.  I am unsure as to how to go about accessing the drop down list for 
the particular row of the button that was clicked.  Any help would be 
greatly appreciated.  Thanks.
Message #2 by "Dave Rezoski" <daverezoski@h...> on Thu, 20 Feb 2003 21:49:19 +0000
I'm not sure what you're planning on doing once you get a handle to the 
dropdownlist, but within the itemdatabound event search the cell that the 
dropdownlist resides in (assuming you know cell that is) ... something like 
this should work...

(in your itemdatabound event handler...)

// item, alt item, or edit item
if(e.Item.ItemType == ListItemType.Item ||
     e.Item.ItemType == ListItemType.AlternatingItem ||
	  e.Item.ItemType == ListItemType.EditItem)
{

myValue = ((DataRowView)e.Item.DataItem).Row.ItemArray[x];
//(where x is the index of the value being returned in your recordset)


// get a handle on the dropdownlist & select correct item
DropDownList ddl = (DropDownList) e.Item.Cells[y].Controls[z];
//(where y is the cell index, and z is the control index)
// now you have a handle to the dropdownlist, so select the item ...
ddl.Items.FindByValue(myValue.ToString()).Selected = true;
}


Hope that helps.








----Original Message Follows----
From: "Hugh McLaughlin" <hugh@k...>
Reply-To: "ASP.NET" <aspx@p...>
To: "ASP.NET" <aspx@p...>
Subject: [aspx] Accessing Drop Down List From a Datagrid
Date: Thu, 20 Feb 2003 21:00:50

Hello everyone and thanks for your help in advance.  I am working on an
application that requires the use of two drop down lists embedded within
a datagrid.  There will also be a submit button for each record in the
grid.  I am unsure as to how to go about accessing the drop down list for
the particular row of the button that was clicked.  Any help would be
greatly appreciated.  Thanks.


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

Message #3 by "Hugh McLaughlin" <hugh@k...> on Thu, 20 Feb 2003 22:11:39
Thanks for the response. Dave.  You lost me a little bit thought.  Why do 
we need an array?  What I am trying to accomplish is to obtain the 
selected item values in the dropdown list of the row that was clicked.  
I'm confused.

Again, thanks for the feedback and patience.

> I'm not sure what you're planning on doing once you get a handle to the 
dropdownlist, but within the itemdatabound event search the cell that the 
dropdownlist resides in (assuming you know cell that is) ... something 
like 
this should work...

(in your itemdatabound event handler...)

// item, alt item, or edit item
if(e.Item.ItemType == ListItemType.Item ||
     e.Item.ItemType == ListItemType.AlternatingItem ||
	  e.Item.ItemType == ListItemType.EditItem)
{

myValue = ((DataRowView)e.Item.DataItem).Row.ItemArray[x];
//(where x is the index of the value being returned in your recordset)


// get a handle on the dropdownlist & select correct item
DropDownList ddl = (DropDownList) e.Item.Cells[y].Controls[z];
//(where y is the cell index, and z is the control index)
// now you have a handle to the dropdownlist, so select the item ...
ddl.Items.FindByValue(myValue.ToString()).Selected = true;
}


Hope that helps.








----Original Message Follows----
From: "Hugh McLaughlin" <hugh@k...>
Reply-To: "ASP.NET" <aspx@p...>
To: "ASP.NET" <aspx@p...>
Subject: [aspx] Accessing Drop Down List From a Datagrid
Date: Thu, 20 Feb 2003 21:00:50

Hello everyone and thanks for your help in advance.  I am working on an
application that requires the use of two drop down lists embedded within
a datagrid.  There will also be a submit button for each record in the
grid.  I am unsure as to how to go about accessing the drop down list for
the particular row of the button that was clicked.  Any help would be
greatly appreciated.  Thanks.


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

Message #4 by Carlos Magalhaes <CarlosM@t...> on Fri, 21 Feb 2003 12:51:12 +0200
Hugh,

 

All you need to do is in the function/sub you need the value do the
following

 

  DropDownList1.SelectedItem.Text() gives you the selected item

 

 

Carlos Magalhaes

Best ADSI and DirectoryServices advice :
http://groups.yahoo.com/group/ADSIANDDirectoryServices
<http://groups.yahoo.com/group/ADSIANDDirectoryServices> 

Best WMI programming advice : http://groups.yahoo.com/group/WMIPROGRAMMING
<http://groups.yahoo.com/group/WMIPROGRAMMING> 

 

-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...] 
Sent: Friday, February 21, 2003 12:12 AM
To: ASP.NET
Subject: [aspx] Re: Accessing Drop Down List From a Datagrid

 

Thanks for the response. Dave.  You lost me a little bit thought.  Why do 

we need an array?  What I am trying to accomplish is to obtain the 

selected item values in the dropdown list of the row that was clicked.  

I'm confused.

 

Again, thanks for the feedback and patience.

 

> I'm not sure what you're planning on doing once you get a handle to the 

dropdownlist, but within the itemdatabound event search the cell that the 

dropdownlist resides in (assuming you know cell that is) ... something 

like 

this should work...

 

(in your itemdatabound event handler...)

 

// item, alt item, or edit item

if(e.Item.ItemType == ListItemType.Item ||

     e.Item.ItemType == ListItemType.AlternatingItem ||

              e.Item.ItemType == ListItemType.EditItem)

{

 

myValue = ((DataRowView)e.Item.DataItem).Row.ItemArray[x];

//(where x is the index of the value being returned in your recordset)

 

 

// get a handle on the dropdownlist & select correct item

DropDownList ddl = (DropDownList) e.Item.Cells[y].Controls[z];

//(where y is the cell index, and z is the control index)

// now you have a handle to the dropdownlist, so select the item ...

ddl.Items.FindByValue(myValue.ToString()).Selected = true;

}

 

 

Hope that helps.

 

 

 

 

 

 

 

 

----Original Message Follows----

From: "Hugh McLaughlin" <hugh@k...>

Reply-To: "ASP.NET" <aspx@p...>

To: "ASP.NET" <aspx@p...>

Subject: [aspx] Accessing Drop Down List From a Datagrid

Date: Thu, 20 Feb 2003 21:00:50

 

Hello everyone and thanks for your help in advance.  I am working on an

application that requires the use of two drop down lists embedded within

a datagrid.  There will also be a submit button for each record in the

grid.  I am unsure as to how to go about accessing the drop down list for

the particular row of the button that was clicked.  Any help would be

greatly appreciated.  Thanks.




 

 

_________________________________________________________________

Add photos to your e-mail with MSN 8. Get 2 months FREE*.  

http://join.msn.com/?page=features/featuredemail

 





Message #5 by "Hugh McLaughlin" <hugh@k...> on Fri, 21 Feb 2003 15:03:20
Carlos,

Thanks for the effort, but this control is located in a datagrid.  Thus I 
need to reference the proper row for the control.

> Hugh,

 

All you need to do is in the function/sub you need the value do the
following

 

  DropDownList1.SelectedItem.Text() gives you the selected item

 

 

Carlos Magalhaes

Best ADSI and DirectoryServices advice :
http://groups.yahoo.com/group/ADSIANDDirectoryServices
<http://groups.yahoo.com/group/ADSIANDDirectoryServices> 

Best WMI programming advice : http://groups.yahoo.com/group/WMIPROGRAMMING
<http://groups.yahoo.com/group/WMIPROGRAMMING> 

 

-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...] 
Sent: Friday, February 21, 2003 12:12 AM
To: ASP.NET
Subject: [aspx] Re: Accessing Drop Down List From a Datagrid

 

Thanks for the response. Dave.  You lost me a little bit thought.  Why do 

we need an array?  What I am trying to accomplish is to obtain the 

selected item values in the dropdown list of the row that was clicked.  

I'm confused.

 

Again, thanks for the feedback and patience.

 

> I'm not sure what you're planning on doing once you get a handle to the 

dropdownlist, but within the itemdatabound event search the cell that the 

dropdownlist resides in (assuming you know cell that is) ... something 

like 

this should work...

 

(in your itemdatabound event handler...)

 

// item, alt item, or edit item

if(e.Item.ItemType == ListItemType.Item ||

     e.Item.ItemType == ListItemType.AlternatingItem ||

              e.Item.ItemType == ListItemType.EditItem)

{

 

myValue = ((DataRowView)e.Item.DataItem).Row.ItemArray[x];

//(where x is the index of the value being returned in your recordset)

 

 

// get a handle on the dropdownlist & select correct item

DropDownList ddl = (DropDownList) e.Item.Cells[y].Controls[z];

//(where y is the cell index, and z is the control index)

// now you have a handle to the dropdownlist, so select the item ...

ddl.Items.FindByValue(myValue.ToString()).Selected = true;

}

 

 

Hope that helps.

 

 

 

 

 

 

 

 

----Original Message Follows----

From: "Hugh McLaughlin" <hugh@k...>

Reply-To: "ASP.NET" <aspx@p...>

To: "ASP.NET" <aspx@p...>

Subject: [aspx] Accessing Drop Down List From a Datagrid

Date: Thu, 20 Feb 2003 21:00:50

 

Hello everyone and thanks for your help in advance.  I am working on an

application that requires the use of two drop down lists embedded within

a datagrid.  There will also be a submit button for each record in the

grid.  I am unsure as to how to go about accessing the drop down list for

the particular row of the button that was clicked.  Any help would be

greatly appreciated.  Thanks.




 

 

_________________________________________________________________

Add photos to your e-mail with MSN 8. Get 2 months FREE*.  

http://join.msn.com/?page=features/featuredemail

 





Message #6 by "Ganesh Walavalkar" <ganesh.walavalkar@w...> on Wed, 26 Feb 2003 09:49:24 +0530
Have u got the ans for the query

Other wise 
U will have to use the findcontrol method of the page to get this thing
done
Regards
Ganesh


-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...] 
Sent: Friday, February 21, 2003 2:31 AM
To: ASP.NET
Subject: [aspx] Accessing Drop Down List From a Datagrid

Hello everyone and thanks for your help in advance.  I am working on an 
application that requires the use of two drop down lists embedded within

a datagrid.  There will also be a submit button for each record in the 
grid.  I am unsure as to how to go about accessing the drop down list
for 
the particular row of the button that was clicked.  Any help would be 
greatly appreciated.  Thanks.


  Return to Index