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

Dynamically fill a GridView Dropdown with the next x years

Is there a way to populate a dropdown in a GridView with the next x years?

I am using a GridView to display data from a SQL table One of the fields is
a Year. I want to have the dropdown list not only the year in the db field,
but also the current year to the next x years.

Any ideas?
Jun 6 '06 #1
3 2090
Just add 1 until the needed year ? What is the exact problem with what you
tried ? (add the items, looping for years, adding the combo etc...)

--

"Advertis" <ad******@snpent.com> a écrit dans le message de news:
kq***************@tornado.tampabay.rr.com...
Is there a way to populate a dropdown in a GridView with the next x years?

I am using a GridView to display data from a SQL table One of the fields
is a Year. I want to have the dropdown list not only the year in the db
field, but also the current year to the next x years.

Any ideas?

Jun 6 '06 #2
here is the senerio:

I have a GridView on a Web Form. The GridView DataSourceID is using a
SqlDataSource to populate the rows in the GridView. The fields returned by
the datasource are: id, month, year. So the rows look somthing like this:

1 1 2003
2 5 2006
3 2 2006

First I changed the year column control in the GridView to a template field
and use a Dropdown. Now I need to add items to the dropdown list for each
row in the GridView to read somthing like this:

row 1 dropdown:
value text
2003 2003 selected
2006 2006
2007 2007
2008 2008
2009 2009

row2 dropdown:
2006 2006 selected
2007 2007
2008 2008
2009 2009

so on and so on

I'm not sure where I actually accomplish this. in the DataBound event, in
the RowAdded event. And then How this is accomplished.

Thanks
"Patrice" <sc****@chez.com> wrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
Just add 1 until the needed year ? What is the exact problem with what you
tried ? (add the items, looping for years, adding the combo etc...)

--

"Advertis" <ad******@snpent.com> a écrit dans le message de news:
kq***************@tornado.tampabay.rr.com...
Is there a way to populate a dropdown in a GridView with the next x
years?

I am using a GridView to display data from a SQL table One of the fields
is a Year. I want to have the dropdown list not only the year in the db
field, but also the current year to the next x years.

Any ideas?


Jun 6 '06 #3
I would use the RowDataBound event. You can get the current year using
e.DataItem. You can then add missing needed years to the dropdown...

--
Patrice

"Advertis" <ad******@snpent.com> a écrit dans le message de news:
GM***************@tornado.tampabay.rr.com...
here is the senerio:

I have a GridView on a Web Form. The GridView DataSourceID is using a
SqlDataSource to populate the rows in the GridView. The fields returned by
the datasource are: id, month, year. So the rows look somthing like this:

1 1 2003
2 5 2006
3 2 2006

First I changed the year column control in the GridView to a template
field and use a Dropdown. Now I need to add items to the dropdown list for
each row in the GridView to read somthing like this:

row 1 dropdown:
value text
2003 2003 selected
2006 2006
2007 2007
2008 2008
2009 2009

row2 dropdown:
2006 2006 selected
2007 2007
2008 2008
2009 2009

so on and so on

I'm not sure where I actually accomplish this. in the DataBound event, in
the RowAdded event. And then How this is accomplished.

Thanks
"Patrice" <sc****@chez.com> wrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
Just add 1 until the needed year ? What is the exact problem with what
you tried ? (add the items, looping for years, adding the combo etc...)

--

"Advertis" <ad******@snpent.com> a écrit dans le message de news:
kq***************@tornado.tampabay.rr.com...
Is there a way to populate a dropdown in a GridView with the next x
years?

I am using a GridView to display data from a SQL table One of the fields
is a Year. I want to have the dropdown list not only the year in the db
field, but also the current year to the next x years.

Any ideas?



Jun 6 '06 #4

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

Similar topics

8
by: utterberg | last post by:
Hi I'm adding two dropdownlist in my webform by clicking a button. I fill the first dropdown with some values from my DB and the other one when I choose from the first dropdown. But since theese...
0
by: yeltsin27 | last post by:
I need some advice on handling dynamically added controls in a GridView. My app takes an uploaded CSV file containing addresses, converts it to a DataTable, databinds the DataTable to a...
0
by: B | last post by:
I was wondering if somebody could point me in the right direction, I have a gridview and it contains a dropdown list, and what I want to do is, than when the dropdown list is modified I want to...
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
0
by: lianaent | last post by:
Hi All, I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can...
1
by: Froefel | last post by:
I'm very new to the ADO.NET and WebForms arena, so the problem that I'm having is probably trivial. Using VS2005, I'm just creating a small test project that has a text box allowing you to enter...
2
by: Cirene | last post by:
I have a gridview that is filtered by a databound dropdownlist. I've set AppendDataBound to True and added the item "ALL" in the dropdownlist. My gridview is supposed to be filtered by this...
2
by: wildman | last post by:
RE: Gridview textbox has data check without postback.. javascript? I have a gridview with a textbox. I can set the textbox to autopostback and check for a value in a prerender event to decide if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
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
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
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.