value from drop down list based on the filter

Posted by Sharu2789 under C# on 7/4/2012 | Points: 10 | Views : 1443 | Status : [Member] | Replies : 1
i need to selct value from drop down list based on the filter in text box in footer row..


Posted by: Premalatha on: 7/4/2012 [Member] Starter | Points: 25

<asp:GridView ID="GridViewUsers" runat="server" AutoGenerateColumns="False" CssClass="TableFramed">
<asp:TemplateField HeaderText="Type">
<asp:DropDownList ID="ddlType" runat="server" AutoPostBack="true">
<asp:ListItem Value="1">Overtime</asp:ListItem>
<asp:ListItem Value="2">Temporary</asp:ListItem>
<asp:ListItem Value="3">Permanent</asp:ListItem>
<asp:TemplateField HeaderText="First Name">
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="FNameValidator" runat="server" Text="*" ControlToValidate="txtFName" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:TemplateField HeaderText="hide me">
<asp:TextBox ID="txtHideMe" runat="server"></asp:TextBox>

code behind

Protected Sub ddlType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
For Each row In GridViewUsers.Rows
Dim reqType As DropDownList = CType(row.FindControl("ddlType"), DropDownList)
Dim txtHideMeAs TextBox = CType(row.FindControl("txtHideMe"), TextBox)

If reqType.SelectedItem.Value = "2" Then
txtHideMe.Visible = "False"
End If
End Sub

Please try it, if u solved your problem, please mail me, and check the anser key

Software Engineer

Sharu2789, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response