<asp:TemplateField HeaderText = "Action"> <ItemTemplate> <asp:DropDownList ID="ddlCountries" runat="server" CssClass="ddl" Width="110px" onselectedindexchanged="ddlCountries_SelectedIndexChanged" AutoPostBack="true" Enabled="true" > <asp:ListItem Text="---Select---" Value="---Select---"></asp:ListItem> <asp:ListItem Text="Pending" Value="Pending"></asp:ListItem> <asp:ListItem Text="Approve" Value="Approve"></asp:ListItem> <asp:ListItem Text="Cancel" Value="Cancel"></asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateField>
protected void ddlCountries_SelectedIndexChanged(object sender, EventArgs e) { string empid = &quot;&quot;; string sno = &quot;&quot;; DropDownList ddl = (DropDownList)sender; GridViewRow row = (GridViewRow)ddl.Parent.Parent; int idx = row.RowIndex; DropDownList ddlStatus = (DropDownList)row.FindControl(&quot;ddlStatus&quot;); Label lblEmpCode = (Label)row.FindControl(&quot;lblSno2&quot;); Label lblsno = (Label)row.FindControl(&quot;lblSno&quot;); empid = lblEmpCode.Text; sno = lblsno.Text; string status = &quot;&quot;; string ApproveId = empCode; if (ddlStatus.Text == &quot;---Select---&quot;) { return; } if (ddlStatus.Text == &quot;Approve&quot;) { status = &quot;Approved&quot;; } if (ddlStatus.Text == &quot;Pending&quot;) { status = &quot;Pending&quot;; } else { status = &quot;Cancel&quot;; } }
GridView
Page_Load
if (!IsPostBack) { ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)