Hey dorsa,
Please refer below sample.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="869px"
Font-Names="Tahoma" AutoGenerateEditButton="True" Style="margin-left: 0px" OnRowEditing="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="Code" HeaderText="کد واحد" SortExpression="Code" />
<asp:TemplateField HeaderText="WeekDay" SortExpression="WeekDay" ItemStyle-Width="150px">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>شنبه</asp:ListItem>
<asp:ListItem>یکشنبه</asp:ListItem>
<asp:ListItem>دوشنبه</asp:ListItem>
<asp:ListItem>سه شنبه</asp:ListItem>
<asp:ListItem>چهارشنبه</asp:ListItem>
<asp:ListItem>پنج شنبه</asp:ListItem>
<asp:ListItem>جمعه</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("WeekDay") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ساعت شروع" SortExpression="StartTime" ItemStyle-Width="250px">
<EditItemTemplate>
<asp:DropDownList ID="ListStartHour3" runat="server" CssClass="TextBox-Align" TabIndex="8"
ValidationGroup="Validate1">
<asp:ListItem></asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ListStartHour3"
ErrorMessage="*"></asp:RequiredFieldValidator>
:
<asp:DropDownList ID="ListStartMinute3" runat="server" CssClass="TextBox-Align" TabIndex="8"
ValidationGroup="Validate1">
<asp:ListItem></asp:ListItem>
<asp:ListItem>00</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>45</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ListStartMinute3"
ErrorMessage="*"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("StartTime") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" EndTime" SortExpression="EndTime" ItemStyle-Width="250">
<EditItemTemplate>
<asp:DropDownList ID="ListEndHour1" runat="server" CssClass="TextBox-Align" TabIndex="9"
ValidationGroup="Validate1">
<asp:ListItem></asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ListEndHour1"
ErrorMessage="*"></asp:RequiredFieldValidator>
:
<asp:DropDownList ID="ListEndMinute1" runat="server" CssClass="TextBox-Align" TabIndex="9"
ValidationGroup="Validate1">
<asp:ListItem></asp:ListItem>
<asp:ListItem>00</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>45</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ListEndMinute1"
ErrorMessage="*"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("EndTime") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Description" HeaderText="توضیحات" SortExpression="Description" />
</Columns>
<EmptyDataTemplate>
<span style="font-family: tahoma">there isn't any defined session for this course</span>
</EmptyDataTemplate>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] { new System.Data.DataColumn("Code", typeof(int)),
new System.Data.DataColumn("WeekDay", typeof(string)),
new System.Data.DataColumn("StartTime", typeof(int)),
new System.Data.DataColumn("EndTime", typeof(int)),
new System.Data.DataColumn("Title", typeof(string)),
new System.Data.DataColumn("Description", typeof(string)) });
dt.Rows.Add(1, "Monday", 10, 12, "t1", "rjhfiuhg");
dt.Rows.Add(2, "TuesDay", 12, 14, "t1", "rjhfiuhg");
dt.Rows.Add(3, "Friday", 15, 18, "t1", "rjhfiuhg");
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
this.BindGrid();
}
Screenshot
![](https://imgur.com/bj2EDRk.gif)