Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Choice of datacontrol(webcontrol)

I would like to know which webcontrol is best choice for my requirement. My requirement is like this.

I have a sql statement which will return resultset of which the first 5 columns will have same value for each row and remaining columns will have different values. I want to display the first 5 column value as header of my report page(which will appear only once) and remaining columns as detail report section.

I tried using datalist but I could not use bind expression in the headertemplate and I am not sure whether I can use datagrid.

any input?

thanks
Ram

RAM
Monday, March 10, 2003


I would use a DataGrid to show the 6th...nth columns. Just make sure that you set AutoGenerateColumns property to false and provide definitions for each and every column.

a) If your resultset has allways the same number of columns, you can do the column definition directly in the XML of the .aspx:

<asp:DataGrid id="theGrid" runat="server" AutoGenerateColumns="False">

<asp:BoundColumn DataField="theNameOfYour6thField" />
<asp:BoundColumn DataField="theNameOfYour7thField" />
...
<asp:BoundColumn DataField="theNameOfYourNthField" />

</asp:DataGrid>

b) If the number of columns is not constant, you can add the columns to the datagrid on the Page_Load event, I dont have the conde handy, but check this out:

http://www.superdotnet.com/show_article.aspx?pkID=116

Regarding the Page Header, just go back to the dataset and extract manually the first five fields of the first row and assign it to your header labels or controls.

Sergio
Tuesday, March 11, 2003

I have a similar problem.  I have a result set that has some columns that repeat through successive rows.  I only want to show the item that repeats once, and then I want to show the rest of the columns for each of the rows with that value.  Like this (not sure if formatting is preserved):

xx  yyy  zz
    uuu  rt
    qwt  er
as  ssq  cv
      saw it

It would seem to mean a nested repeater, but attempts at getting it to work failed.  I did find someone who supposedly did get it working:
http://www.c-sharpcorner.com/Code/2002/Aug/MasterDetailedDisplay.asp
That is a slightly different scenario though.  It might help the original poster.  If anyone has ideas for which control I should use or knowledge that would help, please reply.

Mike Gray
Tuesday, March 11, 2003

I've done nested datagrids before; the trick there is to do the databinding on the inner grid in the ItemDataBound event of the outer grid.

Dave Rothgery
Thursday, March 13, 2003

Maybe this can give you some ideas?
http://cedar.intel.com/cgi-bin/ids.dll/content/content.jsp?cntKey=Generic+Editorial%3a%3anet_templatecolumn&cntType=IDS_EDITORIAL&catCode=BZW

Just me (Sir to you)
Friday, March 14, 2003

*  Recent Topics

*  Fog Creek Home