954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to format a Datagrid ??

I need a datagrid that has 4 columms & 2 rows.
Each cell in that datagrid will represent one row from my database table.

can someone plz giv me some sample code for that ?
or any tips on how to achieve the same ??

Prasadd
Newbie Poster
7 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

In my opinion there are 2 ways of doing it:
1. Make your datasource such that it resembels what is required in the datagrid. Say, For example, you make a array of array and the base array would have table rows in it. So it would be like Array A has two arrays and each of the array has data from the Table row.
and then you simply do a custom binding of your datagrid by calling the event handler of databinding.
2. Other method is more adhoc, where you generate table dynamically. so you declare asp:Table as runat server and then in code behind you add rows and columns in it.

Hope that helps

v_ashwani
Newbie Poster
5 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Hi,

Thanx for ur help !
I'm not much experienced with .NET but will surely try ur suggestions.


Thanx
- Prasadd

Prasadd
Newbie Poster
7 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Hi all here any one knows how to assign color for each rows cell value on the bases of some logics.
Regards.

Ali.

ali_ggl
Newbie Poster
3 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

Hi all here any one knows how to assign color for each rows cell value on the bases of some logics. Regards.

Ali.

try to loop the table then provide the color you wanted to be in every loop... got it? it better to for() statement

jireh
Posting Whiz
316 posts since Jul 2007
Reputation Points: 11
Solved Threads: 49
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You