Click here to Skip to main content
14,924,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello Everyone,
I have 2 drop downlists and a file upload button. When i browse the file and click on the upload button the drop ownlist selected value disappears.please help to fix this issue.
Posted
Comments
Dr Drastic 14-Jul-14 5:17am
   
Could you post some code then we can have a look at where your problem could be
Dilan Shaminda 14-Jul-14 5:21am
   
have you set ViewStateMode="Enabled" for your Dropdownlists?
Raje_ 14-Jul-14 5:23am
   
Can you please add EnableViewState="true" to your Page directive and then check if it works.
Member 10578683 14-Jul-14 5:23am
   
no
jo.him1988 14-Jul-14 5:35am
   
can you post your source view of page here ,make sure about value property of drop down list
Member 10578683 14-Jul-14 5:41am
   
public void BindCName()
{
string qry = "select distinct Customer_Name from Customer_Details";
DataSet ds = du.GetDataSet(qry);
ddlCName.DataSource = ds;
ddlCName.DataTextField = "Customer_Name";
ddlCName.DataValueField = "Customer_Name";
ddlCName.DataBind();
ddlCName.Items.Insert(0, "<--Select-->");
ddlCName.Items[0].Value = "";

}
public void BindCLocation()
{
string qry = "select distinct Customer_Location from Customer_Details";
DataSet ds = du.GetDataSet(qry);
ddlCLocation.DataSource = ds;
ddlCLocation.DataTextField = "Customer_Location";
ddlCLocation.DataValueField = "Customer_Location";
ddlCLocation.DataBind();
ddlCLocation.Items.Insert(0, "<--Select-->");
ddlCLocation.Items[0].Value = "";

}
Member 10578683 14-Jul-14 7:43am
   
<td class="style107" valign="top" colspan="2">

<asp:DropDownList ID="ddlCName" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlCName_SelectedIndexChanged" CssClass="style168"
Height="30px" Width="150px" BackColor="White" Font-Size="8.5pt" ViewStateMode="Enabled">


</td>
<td class="style160" valign="top">
<asp:Label ID="lblH3" runat="server" Text="Customer Location" CssClass="style169"
Font-Size="8.5pt" ForeColor="Black">
</td>
<td class="style162" valign="top" colspan="2">

<asp:DropDownList ID="ddlCLocation" runat="server" CssClass="style168"
Height="30px" Width="150px" BackColor="White" Font-Size="8.5pt" ViewStateMode="Enabled" >
jo.him1988 14-Jul-14 7:31am
   
ohh, here i was talking about your design source VIEW, any way i am not getting any error to get value disappear kind of error
let me guess you call these method on page on load event with check page.ispostback property,
now is auto post back property is true for both dropdown list than set enableviewstate to true
make sure page load you have mention ispostback pro of page
Member 10578683 14-Jul-14 7:55am
   
yes i am calling these methods in page load as follows
if (!Page.IsPostBack)
{
//GridView1.Visible = false;
//lblCurrentDate.Text = DateTime.Now.ToString();
BindCName();
BindCLocation();
}

Enable view state for dropdown.
   
Comments
Nirav Prabtani 14-Jul-14 5:26am
   
my 5+
Member 10578683 14-Jul-14 5:40am
   
ya i enabled view state still it is notworking
if you takes both dropdown in a update panel ..it will prevent from postback of upload button
   

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