Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 12th, 2006, 04:52 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bug Base Query

I am wondering if there is a way to have a grid, say a list of bugs or tickets. And have a nested datalist or repeater as a template column(which would show a list of comments for that particular ticket or bug) and show that template column when the row is selected?

  #2 (permalink)  
Old December 12th, 2006, 05:08 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Yeah, you could do.

First, define the DataList and a datasource inside the template for the GridView item

Next, handle the SelectedIndexChanged event of the GridView to trigger some code when the user selects an item. Inside this event, get the required data from the database directly, or make sure the *DataSource (like an ObjectDataSOurce) control is triggered to get its data from the database.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Voodoo People by The Prodigy (Track 5 from the album: Music For The Jilted Generation) What's This?
  #3 (permalink)  
Old December 14th, 2006, 11:27 AM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, this helps. But how do i add the functionality, so that the Comments column displays count of comments (i can do this by adding that to my objectdatasource and query) but then when the row is selected the row expands to show the comments in such a way like when in-line editing forms mode?
thanks justin

  #4 (permalink)  
Old December 14th, 2006, 05:22 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I am not sure I understand.... Do you want all rows to be editable?

If not, you could embed a nested GridView and set it up with Edit buttons so users can edit a single item at the time.

Alternatively, take a look at this article. It explains how to put a DataGrid in edit mode so multiple rows can be edited at once. More or less the same principles apply to the GridView control.

Personally, I'd consider a separate page for this. Editing multiple items within a GridView can lead to a messy user interface.

If all of this doesn't help, can you describe your requirements in more detail?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #5 (permalink)  
Old December 20th, 2006, 03:27 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Im sorry I was being confusing. What i want is a grid, populated with work ticket records. Each record contains comments which are entered by myself or my colleague in the IT dept. In regular view the grid column for 'comments' would display the number of comments, selecting that row would expand to show the comments, or clicking edit, would expand to show the comments....maybe this is bad design...what i dont want though is a whole page refresh, or a new page, so im trying to implement some ajax here or only partial page refresh....need more explanation, or just more confused now? ha

justin

  #6 (permalink)  
Old December 21st, 2006, 12:43 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Not confused, but maybe you are?

I gave you some suggestions in an earlier post. Have you tried building something based on those suggestions?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old December 22nd, 2006, 06:14 PM
Authorized User
 
Join Date: Jul 2006
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You said you are not sure you understand...to me that means you are confused...

Anyways....I appreciate the post you gave earlier, but thats not really what im trying to do. thats why i re-posted, and tried to redefine what I am trying to do.......I dont want comments shown until the row is selected...in regular item view in gridview i just want to show the number of comments for each row (ticket)....when the row is selected then the comments will be shown. Is there a way to do this in-line on the grid? or is this bad design, what im tring to avoid is passing the ticketid to a new page like you do in your bug base app. I dont want to go to a new page, or even refresh the whole page for that matter...

  #8 (permalink)  
Old December 23rd, 2006, 10:55 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I guess then you're the one that's confused... ;) I think the ideas I presented earlier would work for you....

In the ItemTemplate for the GridView you can set up another GridView (or a DataList or a Repeater or another control). Then when the user clicks a Select button (or another button in the Grid) you handle the SelectedIndexChanged of the GridView. There you can get a reference to the DataKey that is associated with the item that's clicked. Based on this key, you can access the database again, get a list of associated comments, and then bind those to your nested GridView.

Something like this should work:
Code:
<asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" 
    AutoGenerateEditButton="True">
  <Columns>
    <asp:TemplateField HeaderText="SomeField" SortExpression="SomeField">
      <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("SomeField") %>'></asp:Label>
        <br />
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource2">
        <ItemTemplate>
        <asp:Label runat="server" Text='<%# Eval("Comment") %>'></asp:Label><br />
        </ItemTemplate>
        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
              ConnectionString="<%$ ConnectionStrings:SomeConn%>" 
              SelectCommand="SELECT Comment FROM Comments WHERE ([BugId] = @BugId)">
          <SelectParameters>
            <asp:Parameter Name="BugId" Type="Int32" />
          </SelectParameters>
        </asp:SqlDataSource>
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>
As you can see, the template contains a nested SqlDataSource that retrieves the sub items for each main item. The SDS gets a value for the parameter in the code behind.

Code Behind:
Code:
  Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, 
          ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
    Dim id As Integer = GridView1.DataKeys(GridView1.SelectedIndex).Value
    Dim myRow As GridViewRow = GridView1.Rows(GridView1.SelectedIndex)
    Dim mySource As SqlDataSource = CType(myRow.FindControl("SqlDataSource2"), SqlDataSource)
    mySource.SelectParameters(0).DefaultValue = id
  End Sub
  This is not really tested, so you may need to tweak the code a bit to make it work.

Regarding Ajax: did you take a look at the Microsoft Ajax Framework? It offers a lot of features you can use to avoid postbacks in this scenario. It's a bit too much to get into all the details in this thread, but take a look here: http://ajax.asp.net/

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug Base In C# vasancer BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 22nd, 2008 01:20 PM
Bug Base jackandjo BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 January 22nd, 2008 02:31 PM
bug base/DAL ursinho99 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 July 23rd, 2007 01:07 AM
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
Editing Bug Base cf2006 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 6 August 19th, 2006 05:56 PM



All times are GMT -4. The time now is 01:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.