DropDownList SelectedIndex won't set

M

Meagan

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();

}

}


}

}
 
M

Meagan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top