J
jhcorey
I've been googling this and know it's been covered often, but I can't
get mine to work.
I'm using a dropdown list when editing the record in the datagrid.
I'm testing this using an arraylist to populate the dropdown.
The problem is in selecting the item in the dropdown that corresponds
to
the current record's value.
I have the function below wired to the EditCommand event. I'm looking
for the simplest way to select the correct value in the dropdownlist.
I notice in the OnItemDataBound I
have to cast the item cells to textboxes when the item is being edited,
but I'm not sure how to find the value I need.
private void dg_Columns_Edit(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dg_Columns.EditItemIndex = e.Item.ItemIndex;
rptDataTypes = new ArrayList();
rptDataTypes.Add("DESC");
rptDataTypes.Add("ASC");
FillColumnGrid();
DropDownList dl =
((DropDownList)dg_Columns.Items[e.Item.ItemIndex].Cells[5].FindControl("ddlSortDir"));
dl.DataSource = rptDataTypes;
dl.DataBind();
}
get mine to work.
I'm using a dropdown list when editing the record in the datagrid.
I'm testing this using an arraylist to populate the dropdown.
The problem is in selecting the item in the dropdown that corresponds
to
the current record's value.
I have the function below wired to the EditCommand event. I'm looking
for the simplest way to select the correct value in the dropdownlist.
I notice in the OnItemDataBound I
have to cast the item cells to textboxes when the item is being edited,
but I'm not sure how to find the value I need.
private void dg_Columns_Edit(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dg_Columns.EditItemIndex = e.Item.ItemIndex;
rptDataTypes = new ArrayList();
rptDataTypes.Add("DESC");
rptDataTypes.Add("ASC");
FillColumnGrid();
DropDownList dl =
((DropDownList)dg_Columns.Items[e.Item.ItemIndex].Cells[5].FindControl("ddlSortDir"));
dl.DataSource = rptDataTypes;
dl.DataBind();
}