Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a Gridview control do this?

Status
Not open for further replies.

frankyberry

Programmer
Mar 15, 2007
33
US
I'm sitting here trying to decide if I should code the following in a table with a While statement or somehow use a DataGrid control.
Here is what I'd like to display:
Code:
TeamName1  TeamName2   TeamName3
member1a   member2a    member3a
member1b   member2b    member3b
member1c   member2c    member3c

TeamName4  TeamName5
member4a   member4a
member4b   member4b
member4c   member4c

I am having a hard time getting the control to display this data in that order.

Any ideas? How would you people do this?
Which way is "better"

Thanks,
frank
 
How many tables do you have? One way is simply to use a datagrid based on a query (either inline or from a stored procedure).

Something like:

Team Table: Player Table:
TeamID TeamID
TeamName PlayerID
PlayerName

Select teamname,playername
from team,player
where team.teamid = player.teamid

or something very similiar. You can make this as simple or as complex as you want.
 
I'm using a view and for display purposes I'd like to display each team's members under the team name.

Thanks!

 
I would toy with using a Literal control.

Loop through the data you have, (or if it is not quite in the right order use the DataSet's Select method to query each teams data in the dataset and loop though the returned rows) and build a set of HTML tables.

Once you have the html constructed as a big string, set the literal.Text propberty to the html string.

The data controls themselves do not really conform to how you want to diplay this data without using one datagrid per team.

That's my 2 cents anyway.

Senior Software Developer
 
The ListView control might be what you are looking for.

You would still have to loop through the data to format it properly for the ListView, but grouping of the data is simple with it.

See for an example using the data you provided.
 
Oh crap... Sorry. I always get confused about when I'm in which forum. LOL.

This is not the ASP.NET forum obviously, so there is no such literal control for apps. LMAO!

You could create a new datagrid for each team... or use a list view as Borvik sugested.

Senior Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top