473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

dropdown in a grid

I can put a dropdown in a grid column, databind it, and it will work but how
can I get the itemchanged event so that I can do something with it?
thanks,
G
Nov 18 '05 #1
6 1428
Hi,

Try to catch ItemCommand event of datagrid, and use e.CommandSource to get
the handler of dropdown.

Hope it help.

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET

"GaryB" <gb@nospam.com> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl...
I can put a dropdown in a grid column, databind it, and it will work but how can I get the itemchanged event so that I can do something with it?
thanks,
G

Nov 18 '05 #2
Jos
GaryB wrote:
I can put a dropdown in a grid column, databind it, and it will work
but how can I get the itemchanged event so that I can do something
with it?
thanks,
G


Just attach the ItemChanged event as you would with a single
stand-alone dropdownlist.

The ItemChanged event will fire normally, the only problem is
that all of your dropdowns will fire the same event, so you
need to find out which one was changed.

One way to do this would be to use the ClientID property
(through Sender.ClientID), which contains a reference to the
item's index.

--

Jos
Nov 18 '05 #3
The way I handle a normal ItemChanged Event is by using VS.NET, finding the
control in the left dropdown and selecting the event type in the righ
dropdown. But of course, the dropdown in my grid does not appear in that
list.

So, that's why I asked "how can I get the itemchanged event...."
G

"Jos" <jo***************@fastmail.fm> wrote in message
news:ex**************@TK2MSFTNGP15.phx.gbl...
GaryB wrote:
I can put a dropdown in a grid column, databind it, and it will work
but how can I get the itemchanged event so that I can do something
with it?
thanks,
G


Just attach the ItemChanged event as you would with a single
stand-alone dropdownlist.

The ItemChanged event will fire normally, the only problem is
that all of your dropdowns will fire the same event, so you
need to find out which one was changed.

One way to do this would be to use the ClientID property
(through Sender.ClientID), which contains a reference to the
item's index.

--

Jos

Nov 18 '05 #4
Hi Gary,

As for the nested controls in the DataGrid or other template databound
control's template cell, we can directly assign the event handler in the
aspx page source , just like :

...................
<ItemTemplate>
<asp:DropDownList AutoPostBack="True" id="lstItems"
runat="server" OnSelectedIndexChanged="lstItems_SelectedIndexChan ged"
....>
.............

define a handler in the page class, declare as protected or public(can't be
private since it need to be accessable from derived page class)
protected void lstItems_SelectedIndexChanged(object source, EventArgs e)
{
............
}

And here is a former thread which discussing on the same problem, you may
have a look for detailed reference:

#Dropdownlist in template column to fire a SelectedIndexChanged event
http://groups.google.com/groups?hl=e...kwsbiEHA.1280%
40cpmsftngxa10.phx.gbl&rnum=6&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26
q%3DASP.NET%2Bdropdownlist%2Bin%2Bdatagrid%2Bsteve n%2Bcheng

If you have any other questions, please feel free to post here .Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Steven,
a little late but thanks. I finally got back to that project where I needed
to do this an found your answer.
Gary
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Po**************@cpmsftngxa06.phx.gbl...
Hi Gary,

As for the nested controls in the DataGrid or other template databound
control's template cell, we can directly assign the event handler in the
aspx page source , just like :

..................
<ItemTemplate>
<asp:DropDownList AutoPostBack="True" id="lstItems"
runat="server" OnSelectedIndexChanged="lstItems_SelectedIndexChan ged"
...>
............

define a handler in the page class, declare as protected or public(can't
be
private since it need to be accessable from derived page class)
protected void lstItems_SelectedIndexChanged(object source, EventArgs e)
{
...........
}

And here is a former thread which discussing on the same problem, you may
have a look for detailed reference:

#Dropdownlist in template column to fire a SelectedIndexChanged event
http://groups.google.com/groups?hl=e...kwsbiEHA.1280%
40cpmsftngxa10.phx.gbl&rnum=6&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26
q%3DASP.NET%2Bdropdownlist%2Bin%2Bdatagrid%2Bsteve n%2Bcheng

If you have any other questions, please feel free to post here .Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6
Thanks for your followup.

Also, if you meet any further problems, please always feel free to post
here.
Good LUck!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Toonman | last post by:
I have a webpage with a <form> consisting of a large table grid of dropdown lists used to make changes in a database. Some of these dropdown lists have the same value. I'm trying to make it so...
3
by: Dmitry Korolyov [MVP] | last post by:
Is that possible? In other words, I want a dropdown list (and other list-type controls) which appears in edit more of a templated column to be populated with data at the run time. An attempt to do so...
2
by: Spartaco | last post by:
I have a dropdown control into a page and a gridview, both are associated to two SqlDataSource controls, one of them is used to fill the DropDownControl, that is meant to be a filter over the query...
4
by: msch-prv | last post by:
I get a runtime error 'NullReferenceException: Object reference not set to an instance of an object' when I attempt to execute sub UpdGrd() in the Page_Load event. UpdGrd() basically creates a grid...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: Andrus | last post by:
I'm using WinForms DataGridView I need to make dropdown list wider that grid column width. I tried the following code, but dropdown list widht is the same as column width. How to increase...
1
by: jiaudheen | last post by:
hi i work on asp.net,c# my grid view has dropdown in each rows of a column where items can be updated.it several items bound to it. i have added dropdown in in the edit itemtemplate of the grid...
0
by: =?Utf-8?B?VmljY3U=?= | last post by:
Hi All I am working on C# Winforms in VS 2005. I have two datagrids and on the first grid(Shipping Addresses) I have a dropdown column (StateCode) along with other columns. The user can enter...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a generic list of data list <typelistcategory; listcategory = new list <type>; I also have a dropdown box that I have put into a template column of a gridview. I was able to populate...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.