N
needin4mation
Hi, consider this snippet, please:
private void dgdHistory_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string city=null;
if (e.Item.ItemType==ListItemType.Item)
{
Label city_data = ((Label)e.Item.FindControl("lbl_city"));
Response.Write("city: " + city_data.Text);
city = city_data.Text;
}
if (e.Item.ItemType==ListItemType.EditItem)
{
DropDownList ddl_city =
((DropDownList)e.Item.FindControl("ddl_edit_cities"));
ddl_city.SelectedValue = city;
Response.Write("CITY EDITITEM: " + city);
}
}
All I am trying to do is capture the value of my label's text and then
have my dropdownlist in my edititemtemplate default to that value.
So, if the current value of the city is Chicago, then when I press
Edit, the DropDownList should start at Chicago, not the first of the
list. However, I cannot figure out how to capture the current value of
the label to set the SelectedValue or SelectedIndex of the DropDownList
that appears when I press Edit.
Thank you for any help.
private void dgdHistory_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string city=null;
if (e.Item.ItemType==ListItemType.Item)
{
Label city_data = ((Label)e.Item.FindControl("lbl_city"));
Response.Write("city: " + city_data.Text);
city = city_data.Text;
}
if (e.Item.ItemType==ListItemType.EditItem)
{
DropDownList ddl_city =
((DropDownList)e.Item.FindControl("ddl_edit_cities"));
ddl_city.SelectedValue = city;
Response.Write("CITY EDITITEM: " + city);
}
}
All I am trying to do is capture the value of my label's text and then
have my dropdownlist in my edititemtemplate default to that value.
So, if the current value of the city is Chicago, then when I press
Edit, the DropDownList should start at Chicago, not the first of the
list. However, I cannot figure out how to capture the current value of
the label to set the SelectedValue or SelectedIndex of the DropDownList
that appears when I press Edit.
Thank you for any help.