473,406 Members | 2,336 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,406 software developers and data experts.

DropDownList Inside a GridView

I have a Dropdownlist with in a gridview, in my grid I have 10 records, my dropdown values are 1,2,3...10. In first record drop down value is 1, second record dropdown value is 2....

1.now I changed the 5 drop down value to 2, then second drop value is changed to 3 and 3 dropdown has been changed to 4, 4th dropdown has been changed to 5

2.I changed the 5th drop down value to 8, then 8th dropdown value is changed to 7, 7th dropdown has been changed to 6, 6th dropdown has been changed to 5

this is my task plz help me to do t
Attached Files
File Type: zip PAM.zip (7.0 KB, 139 views)
Aug 1 '12 #1
1 2845
Frinavale
9,735 Expert Mod 8TB
Hi sanagasetti,

I cannot download your project so I'm not sure what you've done so far.

I would write a method that handles a DropDownList's SelectedIndexChanged Event. In the template for the column, specify the method for the DropDownList to call during its SelectedIndexChanged event.

In that Method, I would retrieve the DropDownList (casting the sender into a DropDOwnList) so that I could retrieve the row that the DropDownList is representing. You can retrieve the GridViewRow using the DropDownList's NamingContainer.

Once you have the row, you will have to do the necessary work to rearrange the other rows based on what the new selected value is. I think the easiest way to do this would be to rearrange the DataSource that you are using for the GridView based on the newly selected value and the old one...

After you have rearranged the items in the DataSource, you will have to rebind the GridView to it.






Expand|Select|Wrap|Line Numbers
  1. private void dropDownList_SelectionChanged(object sender, SelectionChangedEventArgs e)
  2. {
  3.  
  4.   DropDownList ddl = (DropDownList)sender;
  5.   GridViewRow container = (GridViewRow)ddl.NamingContainer;
  6.  
  7.   // now that you have the row and the drop down list you can
  8.   // determine what the value was, and what it was changed to
  9.   // you have to rearrange the items in the data source that 
  10.   // you are using for your gridview and re bind the gridview
  11.   // to the datasource
  12.  
  13. }
-Frinny
Aug 1 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Pierrick | last post by:
Hello, I have a question about the possibility of using a DropDownList inside a GridView's column (by using a template column). I would like that each DropDownList's content (i.e. for each row)...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
0
by: keithb | last post by:
With a DropDownList in a GridView Edit Template, how can I set the SelectedIndex property so that the list initializes to the value shown in the Display template? When I set SelectedIndex to -1,...
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
0
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
0
by: baburk | last post by:
I am having dropdownlist inside gridview. When the dropdownlist selectedindex change an event should fire. What is the event for his. I also want to get the dropdownlist event fired row...
2
by: baburk | last post by:
I have Two DropDownList inside DataGrid or GridView, Now on Change of selection of First DropDownList, I want to fill value in second DropDownList
0
by: minhtran | last post by:
Hi everyone I have a problem when I want to edit the value from nested dropdownlist in Gridview, Please, anyone can help me to solve this problem, a great appreciation from me in advance. here is...
1
by: shahidrasul | last post by:
i want to bind a dropdownlist in gridview every row has a dropdownlist and then have multiple or single values. problem is that i want when user change value from dropdownlist, we want to show...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...

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.