Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2005, 07:31 PM   PM User | #1
Cipher
Regular Coder

 
Cipher's Avatar
 
Join Date: Dec 2004
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Cipher is an unknown quantity at this point
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
Click image for larger version

Name:	dgTable.jpg
Views:	213
Size:	39.6 KB
ID:	3929  
Cipher is offline   Reply With Quote
Old 10-12-2005, 08:28 PM   PM User | #2
nikkiH
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
nikkiH is on a distinguished road
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/
nikkiH is offline   Reply With Quote
Old 10-13-2005, 12:56 AM   PM User | #3
Cipher
Regular Coder

 
Cipher's Avatar
 
Join Date: Dec 2004
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Cipher is an unknown quantity at this point
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
Cipher is offline   Reply With Quote
Old 10-13-2005, 02:13 PM   PM User | #4
nikkiH
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
nikkiH is on a distinguished road
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/
nikkiH is offline   Reply With Quote
Old 10-13-2005, 05:10 PM   PM User | #5
Cipher
Regular Coder

 
Cipher's Avatar
 
Join Date: Dec 2004
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Cipher is an unknown quantity at this point
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
Cipher is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:18 PM.


Advertisement
Log in to turn off these ads.