Sukesh Shukla
asked on
Problem in using Dropdownlist
I have a dropdownlistFN control for flat_no in which value is fetched from the database, and as i select a value from the list and click on primary member button , the data shown corresponding to the selected value is always for the first flat no which appears 1st in the list on page load , but not for the one which is selected..
kindly help me...
edit_member.aspx
edit_member.aspx.cs
Pdetails.aspx
Pdetails.aspx.cs
kindly help me...
edit_member.aspx
edit_member.aspx.cs
Pdetails.aspx
Pdetails.aspx.cs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HousingConnectionString"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select Flat from Primary_Member", conn);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownListFN.DataSource = dt;
DropDownListFN.DataTextField = "Flat";
DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Pdetails.aspx?fnum=" + DropDownListFN.SelectedItem.Text);
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Fdetails1.aspx?fnum=" + DropDownListFN.SelectedItem.Text);
}
ASKER
On changing it to :
Response.Redirect("Pdetail s.aspx?fnu m=" + DropDownListFN.SelectedIte m.Text);
Still the same thing is happening
Response.Redirect("Pdetail
Still the same thing is happening
I think it's because on page load you refresh the list, so selected value got disappear!
Please apply IsPostBack condition in page load to avoid refreshing the list again on everytime!
Have you tried Lokesh's First Comment [ID: 41133585]?
Please try that and let us know if it works or not!
Please apply IsPostBack condition in page load to avoid refreshing the list again on everytime!
Have you tried Lokesh's First Comment [ID: 41133585]?
Please try that and let us know if it works or not!
ASKER
Thank you Lokesh And Prakash........
Also check whether values comes correctly using debug in code behind