Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Cipher's Avatar
    Join Date
    Dec 2004
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy DataGrid Problem

    is it possible to make table like this with DataGrid, what i want to do is to save all quieries in Datatable then bind it to datagrid which will have most of it BoundColumn, the problem is in the seperator in middle, the main topics!
    Attached Thumbnails Attached Thumbnails DataGrid Problem-dgtable.jpg  

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Use Repeater instead of Datagrid if you want a separator.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder Cipher's Avatar
    Join Date
    Dec 2004
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well here's my problem hope to help me if you got time, check this pictures first: http://www11.brinkster.com/cipherk and here's my Code:

    Dim Conn As New SqlConnection("DataBase = forum;Integrated Security = SSPI")
    Dim ThreadsSql As String = "SELECT COUNT(Threads.ThreadID) AS 'TotalThreads' FROM Threads INNER JOIN Topics ON Threads.TopicID = Topics.TopicID" & _
    " GROUP BY Threads.TopicID, Topics.TopicID ORDER BY Topics.TopicID"

    Dim PostsSql As String = "SELECT COUNT(dbo.Posts.PostID) AS 'TotalPosts', MAX(dbo.Posts.DatePosted) AS 'Latest' FROM Posts INNER JOIN Topics ON Posts.TopicID = Topics.TopicID" & _
    " GROUP BY Posts.TopicID, Topics.TopicID ORDER BY Topics.TopicID"

    Dim dadTopics As New SqlDataAdapter
    Dim dstTopics As New DataSet

    dadTopics.SelectCommand = New SqlCommand(ThreadsSql, Conn)
    dadTopics.Fill(dstTopics, "Threads")

    dadTopics.SelectCommand = New SqlCommand(PostsSql, Conn)
    dadTopics.Fill(dstTopics, "Posts")

    'Thread Titles Array()
    Dim ThreadTitles(5) As Label
    ThreadTitles(0) = jsThreads
    ThreadTitles(1) = htcsThreads
    ThreadTitles(2) = vbsThreads
    ThreadTitles(3) = aspThreads
    ThreadTitles(4) = aspnetThreads
    ThreadTitles(5) = phpThreads

    'Post Titles Array()
    Dim PostTitles(5) As Label
    PostTitles(0) = jsPosts
    PostTitles(1) = htcsPosts
    PostTitles(2) = vbsPosts
    PostTitles(3) = aspPosts
    PostTitles(4) = aspnetPosts
    PostTitles(5) = phpPosts

    'Last Post Title Array()
    Dim LstPostTitles(5) As Label
    LstPostTitles(0) = jsLstPost
    LstPostTitles(1) = htcsLstPost
    LstPostTitles(2) = vbsLstPost
    LstPostTitles(3) = asplstPost
    LstPostTitles(4) = aspnetLstPost
    LstPostTitles(5) = phplstPost

    'Last Post Title Array()
    Dim ForumCond(5) As System.Web.UI.WebControls.Image
    ForumCond(0) = Topic1
    ForumCond(1) = Topic2
    ForumCond(2) = Topic3
    ForumCond(3) = Topic4
    ForumCond(4) = Topic5
    ForumCond(5) = Topic6

    Dim i As Integer
    For i = 0 To 5
    'Add the total Threads of each topic
    ThreadTitles(i).Text = dstTopics.Tables("Threads").Rows(i).Item("TotalThreads")

    'Add the total Posts of each topic label
    PostTitles(i).Text = (dstTopics.Tables("Posts").Rows(i).Item("TotalPosts") - dstTopics.Tables("Threads").Rows(i).Item("TotalThreads"))

    'Add last post of each topic
    LstPostTitles(i).Text = dstTopics.Tables("Posts").Rows(i).Item("Latest")

    'check if there's new posts by checking if there's posts today
    Dim cDay As String = Today
    Dim LatestDate As String = dstTopics.Tables("Posts").Rows(i).Item("Latest")
    LatestDate = LatestDate.Substring(0, LatestDate.LastIndexOf(Year(Today)) + 4)
    If LatestDate = cDay Then
    ForumCond(i).ImageUrl = "img/new_posts.gif"
    ForumCond(i).ToolTip = "New Posts"
    Else
    ForumCond(i).ImageUrl = "img/old_posts.gif"
    ForumCond(i).ToolTip = "No New Posts"
    End If
    Next

    i have never used this way before, what i want is to use DataGrid or Repeater instead of this way, my idea for now is to use DataTable to save in it both queires then bind it to the control, but i'm still not sure if i have a problem in my database or my query, thanks for help.
    i need a creative atmosphere

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I'm not really sure what your question is...

    Do you have VS.NET?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Regular Coder Cipher's Avatar
    Join Date
    Dec 2004
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sure i have, my question is how to show this query in this table by using datagrid or repeater?! and is my work ir right or is there something wrong!
    i need a creative atmosphere


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •