So i have a gridview:
<asp:GridView ID="gvExamSched" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" PageSize="30" Width="1030px" AllowSorting="True" AllowPaging="True" OnRowDataBound="gvExamSched_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ItemStyle-Width="10%" ReadOnly="true"/>
<asp:BoundField DataField="FIRST_NAME" HeaderText="FIRST_NAME" SortExpression="FIRST_NAME" ReadOnly="true" />
<asp:BoundField DataField="MIDDLE_NAME" HeaderText="MIDDLE_NAME" SortExpression="MIDDLE_NAME" ReadOnly="true"/>
<asp:BoundField DataField="LAST_NAME" HeaderText="LAST_NAME" SortExpression="LAST_NAME" ReadOnly="true"/>
<asp:BoundField DataField="EXTN" HeaderText="EXTN" SortExpression="EXTN" ReadOnly="true"/>
<asp:BoundField DataField="OR #" HeaderText="OR #" SortExpression="OR #" />
<asp:BoundField DataField="DATE" HeaderText="DATE" SortExpression="DATE" ItemStyle-Width="15%" />
<asp:TemplateField HeaderText="TIME_FROM" SortExpression="TIME_FROM">
<EditItemTemplate>
<asp:DropDownList ID="ddlTimeFrom" runat="server" Width="80px"></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("TIME_FROM") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TIME_TO" HeaderText="TIME_TO" SortExpression="TIME_TO" />
<asp:BoundField DataField="ROOM" HeaderText="ROOM" SortExpression="ROOM" />
<asp:CommandField ShowEditButton="True" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
Now the dropdownlist (ddlTimeFrom) its data comes from the code behin (c#) which is this:
private void BindTime()
{
DateTime StartTime = DateTime.ParseExact("00:00", "HH:mm", null);
DateTime EndTime = DateTime.ParseExact("23:55", "HH:mm", null);
TimeSpan Interval = new TimeSpan(0,5,0);
ddlTimeFrom.Items.Clear();
ddlTimeTo.Items.Clear();
while (StartTime <= EndTime)
{
ddlTimeFrom.Items.Add(StartTime.ToShortTimeString());
ddlTimeTo.Items.Add(StartTime.ToShortTimeString());
StartTime = StartTime.Add(Interval);
}
ddlTimeFrom.Items.Insert(0, new ListItem("--Select--", "0"));
ddlTimeTo.Items.Insert(0, new ListItem("--Select--", "0"));
}
At first I wasn't using a gridview so I tend to call BindTime() inside page_load for the items in dropdownlist.. but now I need to edit it using gridview but I don't know how...Is it even possible? Cuz if it's not then I guess I'll just have to manually place each time on the Items..Thanks in advance!