Question

Locked

save state of sql dependant ddl's

By slavelabourer ·
Hi,
Before i ask this question i would likejust like to say i'm completely brand new to software development/progamming of any type.

So i'm trying to build three dependant drop down lists.

It almost works correctly but in the second list the user selection is reset to the first database entry on (the second) postback regardless of what the user selects.

the controls are 3 ddl's inside a ajax enabled update panel.

the code behind looks like this.

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected override void OnLoad(EventArgs args)
{
if (this.IsPostBack)
{
this.proName.DataSource = null;
this.proName.DataBind();
base.OnLoad(e);
}
else
{
proName.SelectedValue == null;
}
}


protected void proType_SelectedIndexChanged(object sender, EventArgs e)
{

proName.Items.Insert(0, "");

if( proType.SelectedValue == null) return;
proName.Items.Clear();
string cmd = "select project_name, protype_id from project_names where proType_id = " + proType.SelectedValue.ToString();
pojectNames.SelectCommand = cmd;

SaveViewState();
}


protected void proName_SelectedIndexChanged(object sender, EventArgs e)
{

if (proName.SelectedValue == null) return;
projectActivity.Items.Clear();

string cmd = "select project_activity, type_id from project_activities where type_id = " + proName.SelectedValue.ToString();
projectActivities.SelectCommand = cmd;
SaveViewState();
projectActivity.Items.Insert(0, "");


//proType.Items.Add("boo");
}

}

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Windows Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums