Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Afternoon friends,
I am developing website in Asp.net 3.5 framework visual studio 2008.
What I want to achieve is that I have no of radio buttons and 1 search button in my web page I want the client to search the products according to the radio button select, but none of its event is getting fired.please help me.
Best Regards,
Santosh More
Posted
Comments
db7uk 29-May-12 4:19am    
Are you not able to get the radio button selected value (radio button list) or checked value. By doing so can you not implement your search on the search button click?

In the radioButtonList write AutoPostBack = "True" than 'SelectedIndexChanged' event will fire.

If you want to find the value of the selected radio button then write
RadioButtonList1.SelectedValue;
 
Share this answer
 
Comments
SantoshRohinSantosh 29-May-12 4:36am    
thank you for the ans.
bhagirathimfs 29-May-12 9:09am    
WC :)
XML
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
        <asp:ListItem>Search1</asp:ListItem>
        <asp:ListItem>Search2</asp:ListItem>
        <asp:ListItem>Search3</asp:ListItem>
    </asp:RadioButtonList>
    <asp:Button ID="Button6" runat="server" style="height: 26px" Text="Button" />



Code will be like this:
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButtonList1.Text = "Search1" Then
Search1() ''call function for search1
 Else If RadioButtonList1.Text = "Search2" Then
Search2 ''call function for search2
 Else If RadioButtonList1.Text = "Search3" Then
Search3() ''call function for search3
End If
  End Sub

Private Sub Search1()
''search according to the condition
End Sub

Private Sub Search2()
''search according to the condition
End Sub

Private Sub Search3()
''search according to the condition
End Sub
 
Share this answer
 
Try Like This

XML
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
        <asp:ListItem>Naveen</asp:ListItem>
        <asp:ListItem>Kumar</asp:ListItem>
        <asp:ListItem>aaaa</asp:ListItem>
    </asp:RadioButtonList>
    <asp:Button ID="Button6" runat="server" style="height: 26px" Text="Button" />


IN CS:

VB
Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
      con = New SqlConnection(ConfigurationManager.ConnectionStrings("con").ConnectionString)
      If con.State = ConnectionState.Closed Then
          con.Open()
      End If

      da = New SqlDataAdapter("select * from sample where name='" + RadioButtonList1.SelectedItem.Text + "'", con)
      ds = New DataSet()
      da.Fill(ds)
      GridView1.DataSource = ds
      GridView1.DataBind()
  End Sub
 
Share this answer
 
Comments
SantoshRohinSantosh 29-May-12 5:46am    
thank you i'l try this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900