save state of sql dependant ddl's

By slavelabourer ·
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;
proName.SelectedValue == null;

protected void proType_SelectedIndexChanged(object sender, EventArgs e)

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

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


protected void proName_SelectedIndexChanged(object sender, EventArgs e)

if (proName.SelectedValue == null) return;

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



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