Infragistics ultrawebgrid
-
Can anybody help me to bind data to Ultrawebgrid at runtime dynamically? I dont want to create it at design time at all. When I bind ultrawebgrid just like datagrid, it says, object reference not set to an instance of an object. using Infragistics.WebUI.UltraWebGrid; protected Infragistics.WebUI.UltraWebGrid.UltraWebGrid grid1 ; grid1 = new Infragistics.WebUI.UltraWebGrid.UltraWebGrid(); grid1.DataSource = dataset; grid1.DisplayLayout.AutoGenerateColumns = true; grid1.DataBind(); Please help
rmr
-
Can anybody help me to bind data to Ultrawebgrid at runtime dynamically? I dont want to create it at design time at all. When I bind ultrawebgrid just like datagrid, it says, object reference not set to an instance of an object. using Infragistics.WebUI.UltraWebGrid; protected Infragistics.WebUI.UltraWebGrid.UltraWebGrid grid1 ; grid1 = new Infragistics.WebUI.UltraWebGrid.UltraWebGrid(); grid1.DataSource = dataset; grid1.DisplayLayout.AutoGenerateColumns = true; grid1.DataBind(); Please help
rmr
ok that should work although i normally set the DataMember Property as well, so, it must be taht your dataset is not instantiated? can you post more complete code, including funcitons called from? my best practice for this is to use the designer to bind to a dataset at design time, then change the reference in Pre_Render() like so:
this.dataset = new DataSet();
//
// fill ds here
//this.ultraGrid1.DataSource = this.dataset;
this.ultraGrid1.DataMemeber = "DataTable";
this.ultraGrid1.DataBind();obviously "DataTable" is the name of the table the band is bound to in the grid. regs, g00fy
-
ok that should work although i normally set the DataMember Property as well, so, it must be taht your dataset is not instantiated? can you post more complete code, including funcitons called from? my best practice for this is to use the designer to bind to a dataset at design time, then change the reference in Pre_Render() like so:
this.dataset = new DataSet();
//
// fill ds here
//this.ultraGrid1.DataSource = this.dataset;
this.ultraGrid1.DataMemeber = "DataTable";
this.ultraGrid1.DataBind();obviously "DataTable" is the name of the table the band is bound to in the grid. regs, g00fy
Hi, Here is the code . And when i debug, the dataset is getting populated. The error 'Object reference not set to an instance of an object' pops up at grid1.DisplayLayout.AutoGenerateColumns = true; line in the code. Am now having the grid in design time..and am giving this also <%@ Register TagPrefix="igtbl" Namespace="Infragistics.WebUI.UltraWebGrid" Assembly="Infragistics.WebUI.UltraWebgrid.v2"> Please help. using Infragistics.WebUI.UltraWebGrid; using System.Data.SqlClient; namespace A { public class sample : System.Web.UI.Page { protected Infragistics.WebUI.UltraWebGrid.UltraWebGrid grid1 ; private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { LoadContent(); } } private void LoadContent() { string strConnectionString = "data source=abc" + "Database=Sample;User Id=a;Password=a;"; SqlConnection cnn; cnn = new SqlConnection(strConnectionString); try { cnn.Open(); } catch (Exception ex) { throw ex; } grid1 = new Infragistics.WebUI.UltraWebGrid.UltraWebGrid(); SqlDataAdapter da; DataSet ds1; string s = "select * from a"; ds1 = new DataSet(); da = new SqlDataAdapter (s,cnn); da.Fill(ds1, "Grid"); grid1.DataSource = ds1; grid1.DisplayLayout.AutoGenerateColumns = true; grid1.DataBind(); } private void grid1_InitializeLayout(object sender,LayoutEventArgs e) { grid1.Width = System.Web.UI.WebControls.Unit.Pixel(400); grid1.Height = System.Web.UI.WebControls.Unit.Pixel(400); grid1.Bands[0].AllowAdd = Infragistics.WebUI.UltraWebGrid.AllowAddNew.No; grid1.Bands[0].AllowDelete = Infragistics.WebUI.UltraWebGrid.AllowDelete.No; grid1.DisplayLayout.AllowSortingDefault = AllowSorting.OnClient; grid1.DisplayLayout.AllowColSizingDefault = Infragistics.WebUI.UltraWebGrid.AllowSizing.Free; grid1.DisplayLayout.RowSizingDefault = Infragistics.WebUI.UltraWebGrid.AllowSizing.Free; grid1.DisplayLayout.RowHeightDefault = System.Web.UI.WebControls.Unit.Pixel(22); grid1.DisplayLayout.HeaderStyleDefault.Height = System.Web.UI.WebControls.Unit.Pixel(20); grid1.Columns.FromKey("reportTitle").HeaderText = "Report Title"; grid1.Columns.FromKey("reportTitle").Width = System.Web.UI.WebControls.Unit.Pixel(550); grid1.Columns.FromKey("reportTitle").AllowUpdate = AllowUpdate.No; grid1.Columns.F