Basic thing is thre radio buttons
on dropdownlist
on gridview
when radiobutton 1 is selected the dropdownlist should show the data from YO field of the databse and when 2 is selected the data in dropdownlist should be from YTO and when there is selcted the data should be from adv
and the dropdownlist selected data to be displayed in gridview
code behind in vb
Protected Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim conn As New SqlConnection("server=(local)\\sqlexpress;Database=col_data;Integrated Security=SSPI")
Dim cmd As New SqlCommand()
cmd.Connection = conn
If RadioButton1.Checked Then
cmd.CommandText = "select YO from COURSE_INTAKE"
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
DropDownList1.DataSource = reader
DropDownList1.DataTextField = "YO"
DropDownList1.DataValueField = "YO"
ElseIf RadioButton2.Checked Then
cmd.CommandText = "select YTO from COURSE_INTAKE"
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
DropDownList1.DataSource = reader
DropDownList1.DataTextField = "YTO"
DropDownList1.DataValueField = "YTO"
ElseIf RadioButton3.Checked Then
cmd.CommandText = "select ADV from COURSE_INTAKE"
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
DropDownList1.DataSource = reader
DropDownList1.DataTextField = "ADV"
DropDownList1.DataValueField = "ADV"
End If
DropDownList1.DataBind()
conn.Close()
End Sub
End Class
aspx code
<asp:RadioButton ID="RadioButton1" Text="YO" runat="server" GroupName="Group1" AutoPostBack="true"
Checked="true" OnCheckedChanged="RadioButton1_CheckedChanged" />
<asp:RadioButton ID="RadioButton2" Text="YTO" runat="server" OnCheckedChanged="RadioButton1_CheckedChanged"
GroupName="Group1" AutoPostBack="true" />
<asp:RadioButton ID="RadioButton3" Text="ADV" runat="server" OnCheckedChanged="RadioButton1_CheckedChanged"
GroupName="Group1" AutoPostBack="true" />
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
sqldatasource
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MS16ConnectionString %>"
SelectCommand="SELECT * FROM [Course_intake] WHERE ([Entry_Course] = @Entry_Course)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="Select"
Name="Entry_Course" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>