开发者

Display Table (SQL data) with static & dynamic cells in ASP.NET

good day gurus!

I'm new to ASP.NET and I'm still in the process of learning it.

I was able to finish a couple of aspx pages through searching google but I can't seem to get this one page to work.

Basically, I'm trying to display a table (data fetched from SQL table).

All data are fetched from SQL t开发者_StackOverflow社区able except for these static cells:

Item | Jan | Feb | March | April | Total
Sponge | Rod | Clock | Paper | Prod Cost | Profit
(and all the SUMS)

Display Table (SQL data) with static & dynamic cells in ASP.NET

The "Adjust1" is inserted there if its values are not null. And this "Adjust1" also affects the "Total".

I hope someone can point me to the right direction.

Thanks a lot for your time, Pod


use gridview template feild, just not bind data to your static feild


You can bind your dataset directly to a GrdiView control, and without much manipulation, it will output the columns and rows exactly like your dataset that you returned from the DB.

However, I'm not clear as to what you mean to do with the 'Adjust1' row. Can you explain this in a little more detail?


for the sql manipulation it will be much easier and clean, and create the dataset such a way that it look a like the gridview. This will be a more flexible approach as in future if you want to change any header say display January in place of Jan you dont need any new publish but just a sp update in database

I still you do not want to go with db you can any time achieve this task by using grid rowbound event. Add template fields for calculated columns like total, for displaying the header such jan,feb you can use the headertext property of bound field. For add the value in item field you can pass -1 in the dataset and while bound the grid based on the row index replace the text with required values.

for more details on row databound event read this http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜