473,800 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Day drop down list in GridView

I have a GridView linked to an ObjectDataSourc e, 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.
Nov 19 '05 #1
1 1216
If I understand your question correctly, on the ItemDataBound event you
could do something like this:

If e.Item.ItemType = ListItemType.Ed itItem Then

'look for the ddlWeekDay dropdown
Dim ddlWeekDay As DropDownList =
CType(e.Item.Fi ndControl("ddlW eekDay"), DropDownList)

'populate the dropdown values
Dim mySortedList As New System.Collecti ons.SortedList
Dim Item As DictionaryEntry

mySortedList("0 ") = "Sunday"
mySortedList("1 ") = "Monday"
mySortedList("2 ") = "Tuesday"
mySortedList("3 ") = "Wednesday"

For Each Item In mySortedList
Dim newListItem As New ListItem
newListItem.Tex t = Item.Value
newListItem.Val ue = Item.Key
ddlWeekDay.Item s.Add(newListIt em)
Next

'set the current value held in the database
Dim currentWeekDay As String =
DataBinder.Eval (e.Item.DataIte m, "WeekDay")
Dim li As ListItem =
ddlWeekDay.Item s.FindByValue(c urrentWeekDay.T oString())
If Not (li Is Nothing) Then
li.Selected = True
End If
Hope this helps.
Kat
*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #2

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

Similar topics

1
1179
by: MasterChief | last post by:
I am using a gridview and having it display what is selected in a drop-down list. How do I set it so the gridview will show all by default. I have added an ALL.. item to the item collection of the drop-downlist but how do I make it so that ALL.. will display all the items instead of select ones?
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
6659
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
2964
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
14394
by: McGeeky | last post by:
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
2
1526
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
5
1709
by: Mark B | last post by:
I'd like to have a field in a gridview (or standalone on a webpage) that not only drops down each salespersons name but also precedes their name with a blue, red, green or orange dot icon depicting what group they belong to. Can drop-downs have such graphics as opposed to just text? TIA
3
1863
by: Slickuser | last post by:
Hi, I would like to put a drop down menu in a gridview with the datatype selected from the SQL database. These are the values will show. red orange white green
1
2345
by: slickuser | last post by:
Hi, How can I get the selected value from the drop down menu list inside the GridView command when the user click updated button on that row? Thanks. <asp:BoundField DataField="NAME" HeaderText="NAME" /> <asp:TemplateField HeaderText="Age">
0
10509
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
10281
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...
1
10256
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7584
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
6824
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();...
0
5477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4152
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
2953
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.