http://www.4guysfromrolla.com/webtech/050801-1.shtml
解决方案 »
- 求助:关于gridview的一个问题
- 用户控件中datagrid绑定dropdownlist的问题
- "private System.Boolean _IsGlobal" 与 "private bool _IsGlobal"有没有区别?
- datareader嵌套的问题
- 急问,Session Timeout没到时间,Session就没了,为什么?
- datagrid中动态插入RadioButtonList后如何取得RadioButtonList选中项的值。
- 关于空格和换行的问题,用了转义字符,在有点机上显示正常,有点不能正常显示,原因何在?
- 帮忙贴个msdn文章
- 怎么判断数据库中已经有了其中的一条记录(我是新手)!
- DataGrid统计数据的问题!
- 急:想点击一个textbox弹出一个子窗口(对话框)来进行地域的选择(要分层),怎么办?
- 求www.richtextbox.com的控件(得到将很感激)
public void ItemDataBound(Object sender, DataGridItemEventArgs e)
{
int intCellCount=e.Item.Cells.Count;
DataRowView drv = (DataRowView) e.Item.DataItem;
if (drv == null) return;
//数据类型
if (drv["数据类型"]!=null)
{
TableCell tc = e.Item.Cells[7];
tc.Attributes["Width"]="50px";
string _sql="SELECT DISTINCT a.coldatatype "+
"FROM sys_FlexHeadCtl as a "+
"WHERE (((a.coldatatype)<>'')) "+
"ORDER BY a.coldatatype";
if(oleCn.State!=ConnectionState.Open)
{
oleCn.ConnectionString=strSqlCon;
oleCn.Open();
}
DataSet ds = new DataSet();
OleDbDataAdapter oleDa=new OleDbDataAdapter();
oleCmd.Connection=oleCn;
oleCmd.CommandText=_sql;
oleCmd.CommandType=CommandType.Text;
oleDa.SelectCommand=oleCmd;
oleDa.Fill(ds,"myDDL");
DropDownList ddl=new DropDownList();
ddl.BorderStyle=BorderStyle.None;
ddl.DataTextField="coldatatype";
//ddl.DataValueField="coldatatype";
ddl.Style.Add("BACKGROUND-COLOR","transparent");
ddl.DataSource=ds.Tables[0];
ddl.DataBind();
tc.Controls.Add(ddl);
ListItem li=new ListItem("","");
ddl.Items.Insert(0,li);
if((drv["数据类型"]).ToString()!="")
ddl.SelectedIndex=ddl.Items.IndexOf(ddl.Items.FindByText((drv["数据类型"]).ToString()));
else
ddl.SelectedIndex=0;
}
........
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>