ASP 2.0 databound controls and code behind

  • Thread starter Thread starter Charlie@CBFC
  • Start date Start date
C

Charlie@CBFC

Hi:

The new databound controls (GridView, DetailsView, ect.) use declaritive
syntax (i.e, setup in HTML at design time). However, at times sql
statements and parameters may need to be derived at runtime. In ASP 1.0 we
could do this in code behind, but how do we do it in ASP 2.0? The examples
I see are setting up controls compeletly at design time.

Thanks,
Charlie
 
You can do whatever you want with a GridView at runtime, e.g.


GridView gv = new GridView();
gv.HeaderRow.Cells.Add(new TableCell());
gv.Width = 500;
gv.AllowSorting = true;
gv.DataSource = MyDataSet();
// ...etc
this.PlaceHolder1.Controls.Add(gv);
gv.DataBind();
 
Hi Peter,
Does setting the datasource like you said, don't you loose the ability to
use the builtin update and delete functionallity. I just rewote a page
because I did it this way and could not get the newvalues or oldvalues to
work. Just wondering. I'm still working on getting my page to commpletely
work with the update, but its coming along.
Michael
 
Back
Top