473,789 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drop down list on each GridView row

Hi. I have a read only GridView. For each row I want to display a drop down
list which contains a list of actions the user can select from for that
particular row. E.g. "view details". When they select an action in the drop
down list I want to do a post back. How will I know which row they made the
selection in?

Is there a way to embed the row Id in the drop down list so it gets sent
back to the server?

Thanks
Sep 22 '07 #1
2 14392
Hi,

you don't need the row ID. Instead handle DropDownList's
SelectedIndexCh anged event and in that get reference to the DropDownList
raising the event, you'd get that via sender argument (first argument to the
event handling method)

[VB.NET]
Dim ddl As DropDownList = CType(sender, DropDownList)

[C#]
DropDownList ddl = (DropDownList)s ender;

Then trick is to know how databound controls work. The GridViewRow is naming
container of your DropDownList

[VB.NET]
Dim row As GridViewRow = CType(ddl.Namin gContainer, GridViewRow)

[C#]
GridViewRow row = (GridViewRow)dd l.NamingContain er;

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"McGeeky" <an**@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
Hi. I have a read only GridView. For each row I want to display a drop
down list which contains a list of actions the user can select from for
that particular row. E.g. "view details". When they select an action in
the drop down list I want to do a post back. How will I know which row
they made the selection in?

Is there a way to embed the row Id in the drop down list so it gets sent
back to the server?

Thanks

Sep 23 '07 #2
Cool. Thanks so much for that!!

"Teemu Keiski" <jo****@aspalli ance.comwrote in message
news:uG******** *****@TK2MSFTNG P05.phx.gbl...
Hi,

you don't need the row ID. Instead handle DropDownList's
SelectedIndexCh anged event and in that get reference to the DropDownList
raising the event, you'd get that via sender argument (first argument to
the event handling method)

[VB.NET]
Dim ddl As DropDownList = CType(sender, DropDownList)

[C#]
DropDownList ddl = (DropDownList)s ender;

Then trick is to know how databound controls work. The GridViewRow is
naming container of your DropDownList

[VB.NET]
Dim row As GridViewRow = CType(ddl.Namin gContainer, GridViewRow)

[C#]
GridViewRow row = (GridViewRow)dd l.NamingContain er;

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"McGeeky" <an**@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
>Hi. I have a read only GridView. For each row I want to display a drop
down list which contains a list of actions the user can select from for
that particular row. E.g. "view details". When they select an action in
the drop down list I want to do a post back. How will I know which row
they made the selection in?

Is there a way to embed the row Id in the drop down list so it gets sent
back to the server?

Thanks


Sep 23 '07 #3

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

Similar topics

3
14224
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want to insert the values and text to each drop down list. So i want to create a script that populates a certain Drop Down List with certain values when page loads such as:
2
12624
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
1
1216
by: Diego | last post by:
I have a GridView linked to an ObjectDataSource, when I am in edit mode I'd like to display a dropdownList with the name of the days and when i save the changes I'd like to store 0 for sunday 1 for monday ecc ecc Do you know how can I do it? Thanks, Diego.
1
1224
by: Bishop | last post by:
I made a GridView with a Drop Down List using the example here: http://www.orcsweb.com/articles/dotnet_control_templates.aspx It appears to work except that it dosn't actually save the updated data selected by the drop down list. Instead it appears to save the origional data. Any idea what I might be doing wrong?
0
2648
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
4
6657
by: Bishop | last post by:
I have a query similar to this: "Select ProductID, ProductName, ProductDescription where MFGID = @MFGID". I use a Drop Down List populated with the MFGID's to populate the @MFGID variable. My question is, using this technique, is there a way to say "Return all Manufactures"? If not, any suggestions on a good technique for this?
2
2963
by: CDonlan | last post by:
I'm trying to add a drop down list to a gridview header. The number of columns can change so it has to be done in the code behind (the .cs file). Please help me with this.
2
1525
by: pieandpeas | last post by:
Hi, I am using a gridview to show information from a database nameid | name | address1 | postcode | countryid 1 | bob | 24 green street | ga22ac | 2 and a country table
0
9499
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.