populating gridview controls in edit mode

M

Mike P

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top