动态绑定DATAGRID里的DropDownList

类别:.NET开发 点击:0 评论:0 推荐:
if(e.Item.ItemType==ListItemType.EditItem)
   {
    DataRowView drv=(DataRowView)e.Item.DataItem;
    string currentValue=drv["CUR_ID"].ToString();
    DropDownList ddl=(DropDownList)e.Item.FindControl("ddl_CurInfo");
    DataTable table=ReadCurInfo();
    ddl.DataSource=table;
    ddl.DataTextField="CUR_CHNAME";
    ddl.DataValueField="CUR_ID";
    ddl.DataBind();
    ddl.Items.Insert(0,new ListItem("请选择",""));
    ddl.SelectedIndex=ddl.Items.IndexOf(ddl.Items.FindByValue(currentValue));
   }
   if(e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.Item)
   {
    HyperLink hpl=(HyperLink)e.Item.FindControl("hpy_Attch");
    DataRowView drv=(DataRowView)e.Item.DataItem;
    string fileAttch=drv["OWNMANA_APPENDFILE"].ToString();
    hpl.NavigateUrl=fileAttch;
    hpl.Text=fileAttch.Substring(fileAttch.LastIndexOf(@"\")+1);
   }

本文地址:http://com.8s8s.com/it/it41223.htm