Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
I'm trying to use a dropdownlist in a datagrid edit mode. I'm trying to pres
elect the initial item in the dropdownlist and using the following code...
public void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls
.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
DataRowView myDataRowView = (DataRowView)e.Item.DataItem;
string currentstatus = myDataRowView["Status"].ToString();
DropDownList myDropDownList = (DropDownList)e.Item.FindControl("DropDownLis
t1");
myDropDownList.SelectedIndex = myDropDownList.Items.IndexOf(myDropDownList.
Items.FindByText(currentstatus));
}
}
I keep getting "Specified cast is not valid." error for...
DataRowView myDataRowView = (DataRowView)e.Item.DataItem;
Can anyone help??
Thanks...
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.