hello experties
in my webpage i have one datagrid in datagrid i'm showing all the data.for eg


date/name Title
7/14/2010 Pqrs

abc gh ghfghfghh
ghfghfghfg

7/15/2010 Pqrs

xyz fgh fgh fgh
fdg fgdfgf

7/16/2010 Pqrs

lmn ytyrt yrtyrty

but insted of header text like
Date/Name Title
i want to show the main deiscustion of topic and what thry thinking on the basis other are gives their reply as i shown there.so my table shuld be look like this

7/13/2010 Pqrs
Teacher fgfdgfdgd
fgdfgfgfdgfdg fdg df

7/14/2010 Pqrs

abc gh ghfghfghh
ghfghfghfg

7/15/2010 Pqrs

xyz fgh fgh fgh
fdg fgdfgf

7/16/2010 Pqrs

lmn ytyrt yrtyrty

where color is header which i'm fatching from database and item are in green.
when i'm put the control's in header it shows while i'm designing but it not shows while i'm running the page.
plase help me even i'ed tried gridview also but the same problem with that

Recommended Answers

All 5 Replies

What I might recommend is a dynamically populated set of repeater objects instead of a datagrid.

Basically you set the "fields" of your repeater (labels, text areas, whichever) along with styles and colours of choice and you populate the repeater from your data.

In that way you can have 2x repeaters, one for the primary discussion/original post and one for replies which is a subset of the first one.

When populating the first repeater it populates based on the primary discussion and if the primary discussion has replies you populate the secondary repeater with those.

Unfortunately, it's a bit beyond what I've done with repeaters myself so I can't give detailed code as I've only worked on single-level repeaters myself but I'm sure it can be done :twisted: and it would allow you much more flexibility on formatting and such than the datagrid method.

A good resource for how to use the repeater can be found here.

Hope this helps :)

Edit: I would approach it something like this:

<asp:Repeater ID="Repeater1" runat="server">
            --Repeater format setup--
            <asp:Repeater ID="repeater2" runat="server">
                --Repeater format setup--
            </asp:Repeater>
        </asp:Repeater>

thank you sir for replaying, i had figured the Repeater as per you told me. it work but the problem is still there Header always come one after another. means
1.Question
1.Answer
1.Question
2.Answer
1.Question
3.Answer
i want the fiquer like
1.Question
2.Answer
3.Answer & so on.

Technically, if configured correctly with the 2nd repeater INSIDE the first repeater (which I guess is the tricky part) and the correct data population you should be able to get the effect you're needing with what I supplied.

Basically repeater1 should be configured as a straight up select of all the "questions", repeater2 should be configured to select all answers based on the current question. In that way it SHOULD give your required result.

By configuring as indicated abouve you should get the following:
Repeater1 details
Repeater2 details
Repeater1 details2
Repeater2 details2
Repeater2 details2, 2nd
Repeater2 details2, 3rd
Repeater1 details3
Repeater2 details3

And so on... I'd play around with dynamic population of the dataset for repeater2 based on the current information from repeater1 to achieve this result.

I take it back... after fiddling and playing with the controls I can't get it to do what you want :twisted: The main reason being that the databinding is not controlled enough for me to get a variable into the 2nd repeater representing the message id of the first repeater so it can selectively populate a list of responses related to that item.

Sorry, really thought it would work and if you can find a way to populate the repeaters at the code-behind level instead of the front end data-bind level it would work :)

Thank you sir for Replaying I got the soltion here is my code for that i think this will help other also.
as per you firsttold i had created neasted Repeater and then on form load i'ed written this code for that

protected page_load
dim da as new sqlDataAdpter("Select* from [table1];Select* from [Table2]",con)
dim ds as new dataset
da.fill(ds)
ds.Relations.Add("name",ds.Tables(0).Columns("ID"),ds.Tables(1).Columns("ID"))
 Repeater1.DataSource = ds
 Repeater1.DataBind()
end sub
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater2.ItemDataBound
        Dim dv As DataRowView = TryCast(e.Item.DataItem, DataRowView)
        If dv IsNot Nothing Then
            Dim rpt As Repeater = TryCast(e.Item.FindControl("childrpt"), Repeater)
            If rpt IsNot Nothing Then
                rpt.DataSource = dv.CreateChildView("name")
                rpt.DataBind()
            End If

        End If
    End Sub

and it works.

commented: Nicely done! I was too tired to work it through that far last night :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.