473,387 Members | 1,493 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,387 software developers and data experts.

populating gridview controls in edit mode

I know how to populate a dropdown list in a gridview in edit mode when
the dropdown is populated by a datasource (see below eg 1), but how do
you populate the dropdown when the dropdown is populated in the ASP.NET
(ie you are adding asp:ListItems in the ASP see eg 2) rather than by a
datasource?

Eg 1:

<asp:TemplateField HeaderText="Forecast Type"
SortExpression="ForecastDescription">

<ItemTemplate>

<asp:Label ID="lblForecastType" Text='<%# Eval("ForecastDescription")
%>' runat="server"></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:DropDownList ID="ddlForecastType" DataSourceID="SqlDataSource3"
Runat="Server"

DataTextField="ForecastDescription" DataValueField="ForecastType"
SelectedValue='<%# Bind("ForecastType") %>' />

</EditItemTemplate>

<ItemStyle Height="24px" Width="50px" />

</asp:TemplateField>

Eg2:

<asp:TemplateField HeaderText="Due Date" SortExpression="InvoiceDate">

<ItemTemplate>

<asp:Label ID="lblDueDate" Text='<%# Eval("DueDate", "{0:dd/MM/yyyy}")
%>' runat="server"></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:DropDownList ID="ddlDueDay" runat="server" Width="65px">

<asp:ListItem Value="01">01</asp:ListItem>

<asp:ListItem Value="02">02</asp:ListItem>

<asp:ListItem Value="03">03</asp:ListItem>

<asp:ListItem Value="04">04</asp:ListItem>

<asp:ListItem Value="05">05</asp:ListItem>

<asp:ListItem Value="06">06</asp:ListItem>

<asp:ListItem Value="07">07</asp:ListItem>

<asp:ListItem Value="08">08</asp:ListItem>

<asp:ListItem Value="09">09</asp:ListItem>

<asp:ListItem Value="10">10</asp:ListItem>

<asp:ListItem Value="11">11</asp:ListItem>

<asp:ListItem Value="12">12</asp:ListItem>

<asp:ListItem Value="13">13</asp:ListItem>

<asp:ListItem Value="14">14</asp:ListItem>

<asp:ListItem Value="15">15</asp:ListItem>

<asp:ListItem Value="16">16</asp:ListItem>

<asp:ListItem Value="17">17</asp:ListItem>

<asp:ListItem Value="18">18</asp:ListItem>

<asp:ListItem Value="19">19</asp:ListItem>

<asp:ListItem Value="20">20</asp:ListItem>

<asp:ListItem Value="21">21</asp:ListItem>

<asp:ListItem Value="22">22</asp:ListItem>

<asp:ListItem Value="23">23</asp:ListItem>

<asp:ListItem Value="24">24</asp:ListItem>

<asp:ListItem Value="25">25</asp:ListItem>

<asp:ListItem Value="26">26</asp:ListItem>

<asp:ListItem Value="27">27</asp:ListItem>

<asp:ListItem Value="28">28</asp:ListItem>

<asp:ListItem Value="29">29</asp:ListItem>

<asp:ListItem Value="30">30</asp:ListItem>

<asp:ListItem Value="31">31</asp:ListItem>

</asp:DropDownList>

<asp:DropDownList ID="ddlDueMonth" runat="server" Width="65px">

<asp:ListItem Value="01">01</asp:ListItem>

<asp:ListItem Value="02">02</asp:ListItem>

<asp:ListItem Value="03">03</asp:ListItem>

<asp:ListItem Value="04">04</asp:ListItem>

<asp:ListItem Value="05">05</asp:ListItem>

<asp:ListItem Value="06">06</asp:ListItem>

<asp:ListItem Value="07">07</asp:ListItem>

<asp:ListItem Value="08">08</asp:ListItem>

<asp:ListItem Value="09">09</asp:ListItem>

<asp:ListItem Value="10">10</asp:ListItem>

<asp:ListItem Value="11">11</asp:ListItem>

<asp:ListItem Value="12">12</asp:ListItem>

</asp:DropDownList>

<asp:DropDownList ID="ddlDueYear" runat="server" Width="65px">

<asp:ListItem Value="06">2006</asp:ListItem>

<asp:ListItem Value="07">2007</asp:ListItem>

<asp:ListItem Value="08">2008</asp:ListItem>

</asp:DropDownList>

</EditItemTemplate>

<ItemStyle Height="24px" Width="190px" />

</asp:TemplateField>


*** Sent via Developersdex http://www.developersdex.com ***
Jun 2 '06 #1
0 1541

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

Similar topics

2
by: Playmaker | last post by:
Hopefully someone else has come across this issue. What I have is a SQL Server 2000 back-end. I've created a simple webform which has both Gridview and DataList controls on it populated with a...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
6
by: ibiza | last post by:
Hi all, I have a gridview that can edit data, which is bound to an sqldatasource. Everything works fine, I can update the data via an Edit Command field. However, there are some textboxes in...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
0
by: Larry Bud | last post by:
After spending two days looking at the options in adding a row to a gridview, I came up with my own that I'd like to share. I only can share pseudo-code right now, but maybe in the future I'll...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
3
by: pvong | last post by:
VB.NET How do you change a gridview from Update mode to normal mode? I'm usually dealing for Formviews and there is a ChangeMode option but I don't see one for Gridviews.
0
by: mike0870 | last post by:
Hi, I've been at this one for hours and cannot not find any posts of anyone having the same problem. Ther scenario is, I need to fill a drop down box with a value in the grid row to pass to the...
4
by: ASPnewb1 | last post by:
Hello, I have a 2-dimensional array created from the following text file: data1=asdfawe data2=2 data3=223d data4=22
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.