动态的添加webcombo到webgrid上的操作:

1、在页面中用代码添加一个webcombo.

 ISNet.WebUI.WebCombo.WebCombo wc =new ISNet.WebUI.WebCombo.WebCombo("wcSupplier");
 wc.InitializeDataSource += new ISNet.WebUI.WebCombo.DataSourceEventHandler(wcSupplier_InitData);
 wc.DataTextField = "ContactName";
 wc.DataValueField = "SupplierID";
 Page.FindControl("form1").Controls.Add(wc);
 
2、给webgrid指定的列添加为webcombo

 private void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
 {
  WebGrid1.RootTable.Columns.GetNamedItem("SupplierID").EditType = EditType.WebComboNET;
  WebGrid1.RootTable.Columns.GetNamedItem("SupplierID").WebComboID = "wcSupplier";
  
  WebValueList vl = WebGrid1.RootTable.Columns.GetNamedItem("SupplierID").ValueList;

  if (!vl.IsDataCached())
   vl.DataSource = GetSupplierList();

  vl.DataTextField = "ContactName";
  vl.DataValueField = "SupplierID";
 }
 
3、为webcombo指定资源

 private void wcSupplier_InitData(object sender, ISNet.WebUI.WebCombo.DataSourceEventArgs e)
 {
  e.DataSource = GetSupplierList();
 }

 DataTable GetSupplierList()
 {
  DataTable dt = new DataTable("Suppliers");
  OleDbDataAdapter da = new OleDbDataAdapter("select * from suppliers", oleDbConnection1);
  da.Fill(dt);
  
  return dt;
 }

相关文章:

  • 2021-06-20
  • 2021-05-27
  • 2022-12-23
  • 2022-01-07
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-07-01
相关资源
相似解决方案