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