if(e.Row.RowState == DataControlRowState.Edit)
{
// Preselect the DropDownList control with the state value
// for the current row.
// Retrieve the underlying data item. In this example
// the underlying data item is a DataRowView object.
DataRowView rowView = (DataRowView)e.Row.DataItem;
// Retrieve the state value for the current row.
String state = rowView["state"].ToString();
// Retrieve the DropDownList control from the current row.
DropDownList list = (DropDownList)e.Row.FindControl("StatesList");
// Find the ListItem object in the DropDownList control with the
// state value and select the item.
ListItem item = list.Items.FindByText(state);
list.SelectedIndex = list.Items.IndexOf(item);
}
{
// Preselect the DropDownList control with the state value
// for the current row.
// Retrieve the underlying data item. In this example
// the underlying data item is a DataRowView object.
DataRowView rowView = (DataRowView)e.Row.DataItem;
// Retrieve the state value for the current row.
String state = rowView["state"].ToString();
// Retrieve the DropDownList control from the current row.
DropDownList list = (DropDownList)e.Row.FindControl("StatesList");
// Find the ListItem object in the DropDownList control with the
// state value and select the item.
ListItem item = list.Items.FindByText(state);
list.SelectedIndex = list.Items.IndexOf(item);
}
浙公网安备 33010602011771号