all groups > asp.net webcontrols > october 2005 >
You're in the

asp.net webcontrols

group:

DropDownList SelectedIndex won't set



Re: DropDownList SelectedIndex won't set Meagan
10/29/2005 12:00:00 AM
asp.net webcontrols: I did try that and got the same result... so, I am not sure about the page
rendering and how all those events take place but something must be
misplaced.

Thanks again for any help!!

Nate

[quoted text, click to view]

DropDownList SelectedIndex won't set Meagan
10/29/2005 5:09:49 AM
Hello,

I am stumped...
during Page_Load, the dropdownlist gets the right index integer set to it
but doesn't display the correct item, instead always shows the first item.
I did "Trace.Write(cmbAvail.SelectedIndex.ToString());" and it returns the
proper index but then doesn't display properly. It must be something
simple!

Thanks!

Nathan

void Page_Load(object sender, System.EventArgs e)

{


concon = (ClientConnection) Session["dll"];


if (! Page.IsPostBack)

{

DataTable dtAvailList = concon.AvailList();

cmbAvail.DataSource = dtAvailList;

cmbAvail.DataTextField =
dtAvailList.Columns["avTime"].ColumnName.ToString();

cmbAvail.DataValueField = dtAvailList.Columns["avID"].ColumnName.ToString();

cmbAvail.DataBind();



if (Request.Params["id"] != null)

{ ViewState["id"]=Convert.ToInt32(Request.Params["id"]);


if (Convert.ToInt32(Request.Params["id"]) > 0)

{





Client
client=(Client)concon.FindOutstanding((int)Convert.ToInt32(ViewState["id"]));


txtName.Text=client.FName;

txtLastName.Text=client.LName;

txtStreet.Text=client.Street;

txtAddress2.Text=client.Street2;

txtCity.Text=client.City;

txtZip.Text=client.Zip;

txtEmail.Text=client.Email;

txtPhone.Text=client.Phone1;

txtWorkPh.Text=client.Phone2;

txtMobilePh.Text=client.Phone3;

txtNotes.Text=client.Notes;

Trace.Write("avail1="+ client.Avail1.ToString());

//av1.SelectedIndex=(string)client.Avail1.ToString();

cmbAvail.ClearSelection();

cmbAvail.SelectedIndex =
cmbAvail.Items.IndexOf(cmbAvail.Items.FindByValue(client.Avail1.ToString()));


Trace.Write(cmbAvail.SelectedIndex.ToString());

av2.SelectedIndex=(string)client.Avail2.ToString();

txtDate1.Text=client.AvailDt1.ToString("d");

txtDate2.Text=client.AvailDt2.ToString("d");

ViewState["version"]=client.Version;


DataSet ds=new DataSet();

ds=(DataSet)concon.FindClientSub((int)Convert.ToInt32(ViewState["id"]));

grdPets.DataSource=ds.Tables["ClientSub"];

grdPets.DataBind();

}

}


}

}

Re: DropDownList SelectedIndex won't set Stimp
10/29/2005 5:30:20 AM
[quoted text, click to view]

have you tried using SelectedValue instead?

e.g. cmbAvail.SelectedValue = client.Avail1.ToString()

--

"I hear ma train a comin'
AddThis Social Bookmark Button