Question : asp.net, c#, drop down list error

Hi All,

What I have is four radio buttons and one drop down list.

So rdba, rdbb, rdbc, and rdbd and drop down list called drpFit.  

So what happens now is that if you pick rdba drop down list gets populated if you pick rdbb then drop down list gets populated with relative data.

This works fine.

And data gets shown in a datalist.

This is fine as well.

Now for example if drpfit is at selecteditem = 3 and rdba is checked and i change the rdb to rdbb it still remebers the selecteditem = 3 and throws the error as in the drpFit_selectedindexchanged I am calling cade to build data grid

Code below

please help

Thanks,

R8VI

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
//Another Radio button has been clicked

   protected void rdba_CheckedChanged(object sender, EventArgs e)
        {
            PopulateDropDown (); 
            
        }

   protected void rdbb_CheckedChanged(object sender, EventArgs e)
        {
            PopulateDropDown (); 
            
        }


   protected void rdbc_CheckedChanged(object sender, EventArgs e)
        {
            PopulateDropDown (); 
            
        }


   protected void rdbd_CheckedChanged(object sender, EventArgs e)
        {
            PopulateDropDown (); 
            
        }


//Populate drop down 

public DataSet PopulateDropDown()
        {
            string sSearchType = string.Empty; 
            if (rdba.Checked == true)
            {
                //Bind Drop down 
			dsFit.dataSource                 

            }
            if (rdbb.Checked == true)
            {
                //Bind Drop down 
                
			dsFit.dataSource
                dsFit.Items.Insert(0, "<-- Select -->");

            }
            if (rdbc.Checked == true)
            {
                //Bind Drop down 
                			
			dsFit.dataSource                
dsFit.Items.Insert(0, "<-- Select -->");



            }
            if (rdbd.Checked == true)
            {
                			dsFit.dataSource                
            }
            return dsFil;

        }


//Selected index Change
       protected void drpFilter_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sSearchType = string.Empty;
            string sSearchInput = string.Empty;
            if (drpFilter.SelectedIndex != 0)
            {
                if (rdba.Checked == true)
                {
                    //Bind data grid 

                }
                if (rdbb.Checked == true)
                {
                    //Bind data grid 


                }
                if (rdbc.Checked == true)
                {

                    //Bind data grid 


                }
                if (rdbd.Checked == true)
                {

                }
            }
        }

Answer : asp.net, c#, drop down list error


In my previous comment that I asked to ignore about events, still the line -- drpFilter.Items.Clear(); -- is valid and you should try it. In your code it will be like:

public DataSet PopulateDropDown()
        {
drpFilter.Items.Clear();
            string sSearchType = string.Empty;
            if (rdba.Checked == true)
            {
                //Bind Drop down
                  dsFit.dataSource                

            }
Random Solutions  
 
programming4us programming4us