G
Guest
I just started using ASP.NET yesterday (literally). I've been using ASP for some time, though
This code is in mypage.aspx, and it works just as I intended, showing each table in a separately rendered grid
for (int i = 0; i < 5; i++
{ // iterate through dataset table
grd0.DataSource= dsMain.Tables.DefaultView; //tbl.DefaultView
grd0.DataBind()
%><asp:datagrid id="grd0" runat="server" CellPadding="3" EnableViewState="False"><AlternatingItemStyle BackColor="PaleGreen"></AlternatingItemStyle><HeaderStyle Font-Size="Smaller" Font-Bold="True" ForeColor="White
BackColor="DarkGreen"></HeaderStyle></asp:datagrid><br><
} // end iteratio
This works fine, but I would like to do this in the code-behind page. How can I programatically render the control? Is it simply "grd0.RenderControl;"? Do I have to set all the properties explicitly, or can I copy an unbound prototype DataGrid set up in the Design window and repeatedly rebind the copy? Please give example code
The statement "foreach (DataTable tbl in dsMain.Tables)..." works fine in mypage.aspx.cs, but not in mypage.aspx. At runtime, I got an error saying it could not find the type DataTable. Why not
This code is in mypage.aspx, and it works just as I intended, showing each table in a separately rendered grid
for (int i = 0; i < 5; i++
{ // iterate through dataset table
grd0.DataSource= dsMain.Tables.DefaultView; //tbl.DefaultView
grd0.DataBind()
%><asp:datagrid id="grd0" runat="server" CellPadding="3" EnableViewState="False"><AlternatingItemStyle BackColor="PaleGreen"></AlternatingItemStyle><HeaderStyle Font-Size="Smaller" Font-Bold="True" ForeColor="White
BackColor="DarkGreen"></HeaderStyle></asp:datagrid><br><
} // end iteratio
This works fine, but I would like to do this in the code-behind page. How can I programatically render the control? Is it simply "grd0.RenderControl;"? Do I have to set all the properties explicitly, or can I copy an unbound prototype DataGrid set up in the Design window and repeatedly rebind the copy? Please give example code
The statement "foreach (DataTable tbl in dsMain.Tables)..." works fine in mypage.aspx.cs, but not in mypage.aspx. At runtime, I got an error saying it could not find the type DataTable. Why not