multi row data presented in DataGrid


First off it should be noted that I'm using .Net 1.1 for this - and though I've only been using DataGrid controls for this type of output, there is no reason not to use a Repeater, if it will solve my problem - also I should state that I can't imagine that this is the first time this particular issue has come up, though I haven't figured out how to search for the solution I'm looking for

I think the clearest way for my to describe this issue is to show what my data looks like, and how I'd like to present it

 This is the example SQL query:

Select  Team.tCoach, Team.tCoachCellPhone,  Traveller.trFullName 
From Traveller
INNER JOIN Team ON Traveller.trTeamID = Team.tID

 The results of this query look something like this 

tCoach		tCoachCellPhone		trFullName
--------- -------------- -------------
Tom 123-5314 Macreas, Kent
Tom 123-5314 Bonk, Noa
Peter 123-0000 Carlin, Joe
Peter 123-0000 Kaufman, Laura
Peter 123-0000 Super- Hero

 though what I'd like to present in a DataGrid style, would look more like this


tCoach		tCoachCellPhone		trFullName
--------- -------------- -------------
Tom 123-5314 Macreas, Kent
Bonk, Noa
Peter 123-0000 Carlin, Joe
Kaufman, Laura
Super- Hero
8/21/2007 12:05:57 AM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 49


I think you need to make trFullName a custom template in datagrid and add a repeater control in the custom template. You need to change your sql query so it selects distinct tCoach and tCoachCellPhone and bind it to datagrid, and in GridDataBind event you need to do one more sql query so it will pull out all trFullName from database relating to coach. (You need to pull out coach id as well and make it hidden filed in the grid view so you can use that for subsequent queries)




8/21/2007 12:45:19 AM

Ops the event name is Grid_ItemDataBind.

8/21/2007 12:46:33 AM

ok, I think I followed what you're getting at

I bound the datagrid with the query:

 Select DISTINCT Team.tCoach, Team.tCoachCellPhone, Team.tID
From Team

and then added the Template Column to the datagrid, using the repeater

<asp:TemplateColumn HeaderText="Traveler">
<asp:Repeater id="Repeater1" runat="server">
<%# Container.DataItem( "trFullname" )%> </ItemTemplate>

then using the DataGrid1_ItemDataBound event (Grid_ItemDataBind wasn't an option), I run my query, fill the dataset 

strSql = "SELECT  trFullname FROM Traveller " 
strSql += " WHERE trTeamID = " & e.Item.Cells(1).Text()
strSql += " ORDER BY trLastname" SqlSelectCommand1.CommandText = strSql
SqlConnection1.ConnectionString = ConfigurationSettings.AppSettings("Conn")
Repeater1.DataSource = dsRepeater

and then get an Object reference not set to an instance of an object error on

Repeater1.DataSource = dsRepeater

When I test this dataset with a repeater that isn't nested in the datagrid, it works fine - is there a different way to fill the repeater, or do I create a new instance of the repeater for each row (coach in this example)?

8/21/2007 10:35:45 PM

 solved my problem - I found the control and created a new instance of it

Dim rptChild As Repeater = e.Item.FindControl("Repeater1")
rptChild .DataSource = dsRepeater
rptChild .DataBind()
8/22/2007 12:36:01 AM

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

Is there any way to control the width of the Gridcolumn when the data is present and not present
I would like to know if there is any way you can control the gridview column width. Thanks in advance. Digish Hi,   try these link this post was useful to you, please Don't forget to click "Mark as Answer". Thanks You.:-)...

Presentation Control for multi-row view
Hello, I have created a database for fights that we have at our events. The fight table consists of a FightId, Fighter1, Fighter2, and an EventId. Fighter1 and Fighter2 are foreign keys of the fighter table, and the EventId is a foreign key of the Event table. There are more fields, but for the purpose of this question, they do not matter. So here is the scenario: I am trying to create a fight card app that allows the user to view upcoming fight cards and view previous event results using our database to provide this information and keep it up to date with only having to make alteration...

Reformat sql data from for presenting in datagrid control
Hi everybody  I have an sql query that gets this data from a couple of tables dia exe_seg ser_seg Segunda Supino Plano 3x12 Segunda Supino Inclinado 3x12 Segunda Aberturas com Alteres 3x12 Terça Abdominais 3x20 Terça Lombares 3x20 Terça Passadeira 15' Quarta Remada Baixa 3x12 Quarta Fundos 3x12 Sexta-Feira Remo 15' and I would  and I would like to bind it to a datagrid but with a different format, like this, ...

How do the different data presentation controls equate in
How does Visual Studio create equivalents of the datagrid's and gridview's columns and rows?  I am assuming they make a DataRow for each of the rows.  Am I on the right track with this?Is the table created by gridview basically a dataset from  Can anyone offer any guidance with this?Thanks to everyone that has ever helped me with any posts. Hi newbie2C#, The row in datagrid is called DataGridItem and in gridview is called GridViewRow. They are all inherits TableRow Class. DataRow is only one kind of row in GridView control. There are many other t...

Data presentation without a data control
The Gridview and Formview controls provide good functionality in some circumstances but are clumsey in others. As a newbie to .NET I was wondering if its appropriate to do databinding with textboxes and other data controls outside of one of the new data controls (formview, gridview, etc). Or is it a new standard to always use one of the new data controls. If the answer is yes, would you still use an SQLDatasource, or would you set up the connection in code? And, how would you deal with the syntax? In the Formview we have: <asp:TextBox ID="fnameTextBox" runat="server" ...

ajax control in data presentation controls
can i add ajax controls (MaskedEdit) to presentation controls (dataGrid, dataForm)?? Hi,of course. But keep in mind that those controls are extenders, so you append them to an existing control. Just convert your GridView / DetailsView-fields into templated fields and add the extender you'd like to use to the controls.RegardsMarco Buerckel Don't forget to mark posts that were helpful as answers. Actually, if you looked at the source code for the Masked Edit Extender, you'd see  [TargetControlType(typeof(TextBox))]Meaning, targeting any control type other than textboxes...

Data Presentation Controls and complex data+logic
I'd like to know how people solve problem of binding complex data to data presentation controls. As we all know, real life is not as simple as webcasts etc. assume.Lets say we have something like this.List<Person> liPerson = PersonFactory.GetAllPersons();List<Company> liCompany = CompanyFactory.GetAllCompany();And I want a table something like this:Microsoft      Bill      JohnIBM      Ted      CharlesNokia      Matti Is there a generic solution to...

data presentation controls (how to call the individual controls)
Hi please help me.,i have this question., example i create a site with one control, like textbox. when i double click on the white page, the page load event, in the intellisense, the textbox is visible, but when a formview with a textbox inside, in the same page load event, intellisense, the textbox is not available. how can i do the simple intellisense calling where the textbox is just outside a data presentation control like formview. i mean by this intellisense calling is in VB code view., thanks JFRBPH12™  The textbox is within the formview then you can find it like this...

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

Data Presentation controls
Hi Is there someone how use data presentation controls? I found it for free on Thanks There are data presentation controls built into ASP.Net 2.0 (GridView, Detailsview, etc) Of which controls are you speaking?David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as Answer' when it applies)...

Which Data Presentation Control?
hi in my project i have a  directors page which includes their picture information and filmography. I want to show filmography in different data presentation control than the other data. And i want to show it with this stored procedure: select Film from Films inner join Film_Director on .fid where yid=@id but i have InCollection field in Films table and in my data presentation control i want to change the color of Film's Text by InCollection. If InCollection=true for that movie that row's text should be green if false should be red for example.  S...

Getting Information from the Controls (TemplateField or BoundField ) from any of the Data Presentation Controls
Hello Everybody,I have a very important question for me.For example, I have a GridView.It has three BoundFields and one TemplateFieldI want to get information from any of the record (row,line etc ) using any of the BoundFields or TemplateFields.And also I want to accomplish this not only with GridView but also other Data Presentation Controls, DetailsView FormView and Repeater.Shortly, Can anybody help me how to refer Controls in GridView, FormView, DetailsView, RepeaterPS: I have searched in Google and many sites,forums. But I couldn't see any solution and see that many people ask the same ...

Web resources about - multi row data presented in DataGrid -

Obama: We have cut off every path for Iran to obtain nuclear bomb
"This is a good day because once again we are seeing what's possible through strong American diplomacy," Obama said at the White House, adding ...

Survivors Recall Narrow Escape From Burkina Faso Attack
Wall Street Journal Survivors Recall Narrow Escape From Burkina Faso Attack New York Times OUAGADOUGOU, Burkina Faso — As al-Qaida fighters ...

NBC’s Packers-Cardinals Playoff Game Sets Divisional Ratings Record
Last night’s overtime NFC Divisional Playoff game between The Green Bay Packers and Arizona Cardinals has posted an 18.8/33 household rating ...

Search for 12 Marines from downed helicopters enters 3rd day Search for 12 Marines from downed helicopters enters 3rd day A search vessel cruises the waters off the beach at ...

Tsai Ing-wen: Who is Taiwan's first female president, leader of the Democratic Progressive Party?
Law professor turned DPP leader, nicknamed 'Little Ing', breaks the pattern for Asian women in politics.

Jeremy Corbyn says we need back channels to ISIS to end to the Syrian war
The Labour leader stopped short of calling for dialogue with ISIS but compared the situation to when the British government had lines of communication ...

United beats Liverpool 1-0 to spark talk of title challenge
LIVERPOOL, England (AP) — Manchester United relied on brilliant goalkeeping by David de Gea and an opportunistic finish by Wayne Rooney to snatch ...

Man Evicted From Homeless Shelter Returns The Next Day, Shoots Two Employees, One Dead
A homeless man was evicted from a Philadelphia homeless shelter but returned the next day to gather his belongings. When he returned, he came ...

Marco Rubio Says He Bought A Gun On Christmas As 'Last Line Of Defense' Against ISIS
Many Americans were wishing for "Peace on the earth, good will to men" while celebrating Christ's birth, but Republican presidential candidate ...

Martin Luther King had complicated legacy on gun violence Martin Luther King had complicated legacy on gun violence Miami Herald Martin Luther King Jr. was surrounded by guns, even though ...

Resources last updated: 1/17/2016 10:38:38 PM