Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Rows in v1.1 Datagrid to go to new line

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-06-15 : 09:28:03
I'm not too sure if this is possible, but what I need to do is show about 18 columns for a single record in a datagrid, but I'm thinking I need to break it up into 3 datagrids of 6 columns.

What we have is a PK (WorkerID), which has a budget amount for each year starting @ 2004 going up to 2020. So, a record would look like:

ID FY04 FY05 FY06 FY07 FY08 FY09 FY10..........FY20
1 $22 $33 $45 $10 $0 $50 $55 $100

In Access, you can make the first row 6 text boxes, then the second row 5 text boxes, then the third row 4 text boxes....and so on for each of the budget years. I know the controls aren't the same, but this is what we want to mimic in ASP.NET 1.1.

Right now, we're only showing 2006 through 2010, so the width isn't an issue. But with customer requests, we're thinking about changing the page. May have to ditch the Datagrid....

Thanks!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-06-15 : 10:02:55
Sounds like you need to use a Repeater and/or a DataList.

If you use a DataList, you get most of the features of the datagrid, but you need to do some work to create a well-formed multi-column table since by default it just outputs a single column table wrapped around your content. To do this, you use the ExtractTemplateRows=True attribute, and then you define your table using server-side Table tags. It takes some getting used to , but it works quite well and the server controls for tables can be nice to work with in some cases.

So, you'd end up with something like this:

<asp:DataList runat="server" .... ExtractTemplateRows="True">
<ItemTemplate>
<asp:Table>
<asp:TableRow>
<asp:TableColumn/> <asp:tableColumn/> .. etc...
</asp:TableRow>
<asp:TableRow>
<asp:TableColumn/> <asp:tableColumn/> .. etc...
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:DataList>


.. for a "two table rows per data row" output, like you described. The <asp:Table> tag is ignored, and when databinding, the DataList will output your table rows one by one for each data item it binds to. Note that you must use the server TABLE controls, not the usual HTML <table> and <td> tags.

See the MSDN help files for more info on ExtractTemplateRows; it is rarely used but a great feature. Also, play with it on some small sets of sample data with only a few things in your template before trying to implement it for the first time on your 100 column page.
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-06-15 : 22:45:37
jsmith8858,

Thanks a lot for the help!

I'll look into that!
Go to Top of Page
   

- Advertisement -