Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
binding a webgrid
posted

 I am a newbie on Infragistics 2008.1. Previously we used 2006.3 for .Net 1.1.

 My dilemma is that I am trying to create a grid, design the columns (some hidden, and other kids of formatting) and bind it to data. For .Net 1.1 I used to simply create a dataset at design time and bound it after loading the dataset on page_load of the page. How will you do this now? For VS 2008, I now cannot drag a dataset on design mode to the page, and can only bind it to sqldatasource, objectdatasource et al. I tried the objectdatasource route, on select method I created and returned a dataset but this wipes out my previous formatting. Is there a quick HOW-TO for how to bind a webgrid to data for .Net 2.0 (and up) anywhere?

Thank you! 

Parents
No Data
Reply
  • 1332
    posted

    In VS 2008 you can add a DataSet to your project by right-clicking the project file in Solution Explorer and choosing Add New Item. Select DataSet in the Add New Item dialog box. You will be prompted to add the DataSet to your AppCode folder. Accept, the wizard to hook up your DataSet to data appears. It should be pretty self-explanatory from this point on to connect to your data. You have a named DataSet after you connected to a database after you are finish. The steps to bind to WebGrid are as follows: declare your DataAdapter and DataSet in code, fill your data, and bind to WebGrid.

    An example of binding to a Customers table from northwind is as follows:

    CustomersTableAdapter sqlDataAdapter1 = new CustomersTableAdapter();
    DataSet1 dataSet11 = new DataSet1();

    sqlDataAdapter1.Fill(dataSet11.Customers);

    this.UltraWebGrid1.DataSource = dataSet11.Customers;
    this.UltraWebGrid1.DataBind();

    The other issue here it seems is that you are trying to create a design time schema. For a tutorial on this, take a look at this article:

    http://help.infragistics.com/Help/NetAdvantage/NET/2008.1/CLR2.0/html/WebGrid_Changing_the_Appearance_of_Bands.html

    The basic concept includes adding columns that you want to show for the DataSet that you will bind to. These columns are unbound, and the BaseColumnName property is set to the column name in the DataTable. If the data is hierarchical, add additional bands and set the BaseTableName of each band. This process results in the grid showing only what you designed at design time for the data bound at runtime.

Children