Click here to Skip to main content
15,909,503 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a radiobutton list which contains option for student and employee . If user selects student then student fields will be come and if user selects employee then employee fields will come on same page. How to do it
Posted

Its not a valid question. Just take a look at this. ASP.NET RadioButtonList Control[^] & its example[^]

For your requirement, get the value in OnSelectedIndexChanged[^] event.

Go ahead.
 
Share this answer
 
use this code as per your requirement...

C#
protected void rdbList_SelectedIndexChanged(object sender, EventArgs e)
{
    string table = "";
    if (rdbDBSelection.SelectedIndex == 1)
    {
        table = "STUDENTLIST";
    }
    if(rdbDBSelection.SelectedIndex == 2)
    {
        table = "EMPLOYEE";
    }
    GetList(table);
}
GridView GridView1 = new GridView();
protected void GetList(string tableName)
{
    string query = "SELEFCT * FROM " + tableName;
    // fro firing select query and filling data table or data set code will goes here...
    // use that data table or data set as data source to your control like gridview or list view
    // here i use a grid view for demo perpose
    GridView1.DataSource = ds;
    GridView1.DataBind();
}
 
Share this answer
 
Comments
thatraja 8-Nov-11 9:20am    
Nice effort, 5!
hi,

Place all the student related fields in one panle and all the employee related fields in one panel.

When you click student radiobutton then set student panel visibility to true

When you click employeeradiobutton then set employee panel visibility to true

When you load page for first check one radiobutton by default and make corresponding panel visible


Hope this helps,

Thanks & Regards
Sriman
 
Share this answer
 
Comments
thatraja 8-Nov-11 9:21am    
Simple, 5!
Tejas Vaishnav 9-Nov-11 5:35am    
i think it will use more memory and also taking time when data is more, so try other way that's not correct way.....but nice effort....

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