Visual Studio .NET - dropdown list invisible:-(

Asked By ruchi punetha on 29-Mar-06 04:11 AM
hi
i have a dropdown list in my form which is beeing visible at radiobutton's selection and filling data from database.
when i want to change the selected item of the lidt it got invisible.what should ido?

dropdown list invisible - Asked By Pankaj Sharma on 29-Mar-06 04:46 AM

I think you should check your code properly. You might have made drop down invisible on the SelectedItem_change event or some where else in your code by setting drop down control's visible property.

problem - Asked By ruchi punetha on 29-Mar-06 05:03 AM

hi pankaj
there is everting fine but now what is happing when i m changing the selected index the item in dropdownlist text is remain unchange.selection change is not working.

problem - Asked By Pankaj Sharma on 29-Mar-06 05:40 AM

Have you set the AutoPostBack property of dropdown list to true.
It is necessary, because as soon as you select another value in drop down list it must be posted back itself and reloaded with the new selection.

Hope this could solve your problem.
still not done!! - Asked By ruchi punetha on 29-Mar-06 09:21 PM
hi pankaj
ye i did everything fine and i know bout autopostback & i had setted it  true in start but still it is not working ... i m sending u some code
<form id="Form1" method="post" runat="server"> 
<table id="Tabel1" style="Z-INDEX: 101; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 50px" cellSpacing="1" cellPadding="1" runat="server"> 
<tbody> 
<TR> 
<TD style="WIDTH: 174px; HEIGHT: 44px"></TD> 
<TD style="WIDTH: 451px; HEIGHT: 44px"><FONT color="red">This type of Tech service isfor ADMIN Who can redirect made any new Complain nad sub complain,and can provide new form </FONT> 
</TD> 
</TR> 
<tr> 
<td class="dataTD" style="WIDTH: 191px" width="191" height="10">               Add New Category</td> 
<td><asp:button id="Button1" runat="server" Text="Click Here" Width="110px"></asp:button></td> 
</tr> 
<tr> 
<td class="dataTD" style="WIDTH: 191px" width="191" height="10"></td> 
<td colSpan="2"> 
<P><asp:button id="newC" runat="server" Text="Add New Complain" Width="134px" Visible="False"></asp:button>       
<asp:button id="newSC" runat="server" Text="Add New SubComplain" Width="154px" Visible="False"></asp:button></P> 
<td colSpan="2"><p> 
<asp:DorpDownList id=helpform runat="server" AutoPostBack=true>
</asp:DropDownList>
<uc1:Complain id="Complain1" runat="server"></uc1:Complain></P></td> 
</tr> 

now in code behind of parent page 
private void Page_Load(object sender, System.EventArgs e) 
{ 

} 

private void Button1_Click(object sender, System.EventArgs e) 
{ 
newC.Visible=true; 
newSC.Visible=true; 
} 

and in user control 
private void Page_Load(object sender, System.EventArgs e) 
{ 
try 
{ 
SqlDataAdapter mycomm2= new SqlDataAdapter("select distinct(panel) from problem_table",myConnection); 
DataSet ds2=new DataSet(); 
mycomm2.Fill(ds2,"processdept"); 
helpform.DataSource = ds2.Tables["problem_table"].DefaultView; 
helpform.DataTextField = "panel"; 
helpform.DataBind(); 
helpform.AutoPostBack=true; 
} 
catch(Exception er) 
{ 
Response.Write(er); 
} 
// Put user code to initialize the page here 
} 



private void newC_Click(object sender, System.EventArgs e) 
{ 
newC.Visible=false; 
newSC.Visible=false; 
add.Visible=true; 
} 
} 

private void helpform_SelectedIndexChanged(object sender, System.EventArgse)
{
if(helpform.SelectedItem.Text=="folder")
Complain1.Visible=true;//it is a user ontrol but i cannot access its property i m just writing here i m not getting propertioe while after plscing dot .and the nam of user contol is alse same.
}
			

but it is not working.namspace are same for both. 
plz help to solve this ..
done - Asked By ruchi punetha on 30-Mar-06 02:46 AM
look at this code 
private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e) 
{ 
try 
{ 
SqlCommand mycomm= new SqlCommand ("select panel from problem_table where problem=@sel and sub_prob=@sel1 ",myConnection); 
mycomm.Parameters.Add( "@sel",DropDownList1.SelectedItem.ToString()); 
mycomm.Parameters.Add( "@sel1",DropDownList2.SelectedItem.ToString()); 
SqlDataReader myread; 
myConnection.Open(); 
myread=mycomm.ExecuteReader(); 
string StrVal; 
while (myread.Read()) 
{ 
int pan__Ordinal = myread.GetOrdinal("panel"); 
StrVal=myread.GetString(pan__Ordinal); 
Response.Write(StrVal); 
UserControl myControl=(UserControl)this.Page.FindControl(StrVal); 
myControl.Visible=true; //Found the control. 

} 
myConnection.Close(); 
} 
} 

i dont know y but it was a very unusual thing that put the string variable initialization outside he loop.and this worked. 
Thanks for everyone who tried for it.