string InOrOut=......DropDownList ddl_InOrOut=(DropDownList)DataGrid1.Items[i].Cells[4].Controls[1];

ddl_InOrOut.SelectedIndex=ddl_InOrOut.Items.IndexOf(new ListItem(InOrOut,InOrOut));

解决方案 »

  1.   

    private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    DropDownList dpl;
    dpl=(DropDownList)e.Item.FindControl("DropDownList1");
    dpl.SelectedIndex=3;
    }
      

  2.   

    DropDownList ddl_InOrOut=(DropDownList)DataGrid1.Items[i].Cells[4].Controls[1];
    如果是模板列,是不是应该是.Controls[0]?
      

  3.   

    也可以在ItemDataBound事件中,对DropDownList进行初始化操作。