Multiple DataGrid in an ASPX page

R

Raja

Hi,
I have a requirement in which I need to display multiple
datagrids in my ASPX page. I do not know how many of them
until the page load.
So I tried to approach this problem in the following ways
but none worked.

Method 1:
Step 1. Create a custom web control with a datagrid in it.
Step 2. Place a placeholder control in my page
Step 3. Create multiple instance of custom control and add
those to placeholder control
This failed, beacuse when i try to access the datagrid
control inside the custom webcontrol it gives "object
reference.. " error

Method2:
step 1: have a repeater control in the form
step 2: Inside the itemtemplate of repeater control have a
datagrid.
I still have questions about how to set the datasource for
both datagrid and repeater control.

Method 3:
step 1: have a place holder control in the form
step 2: create datagrid control in the form at runtime
This method seems to be working.. but I am unable to set
headerstyle and other properties for the dynamically
created (at run time) datagrid. because they are all
readonly properties.

Could any one tell me how to do this. Do you guys think
all of the above methods are wrong? Any code sample would
be a great benefit.

Thanks in advance,
Raja
 
J

James Williams

Raja,

Use a stylesheet and the CssClass property.

Example:
DataGrid grid = new DataGrid();
grid.HeaderStyle.CssClass = "MyHeaderStyle";
grid.FooterStyle.CssClass = "MyFooterStyle";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top