Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | 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 January 25th, 2007, 08:51 AM
Registered User
 
Join Date: Jan 2007
Location: barcelona, spain, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default assign a user to a bug?

Hi!
I'm going mad trying to develope a little more the bugbase...
I want to assign a bug to a user (that exists in the aspnet_user file).

In the addeditbug.vb and .aspx I added a dropdownlist to select the user, also I've added I new field called reportmemberId in the Bug table...

I can save the Bug correctly, with the reprtmemberid included, but when I edit the bug I don't know
the way to recover and, after, find the value Id (guid) for this user, and show it
like the feature (for example).

 If lstFeature.Items.FindByValue(myBug.Feature.Value.T oString()) IsNot Nothing Then
                    lstFeature.Items.FindByValue(myBug.Feature.Value.T oString()).Selected = True
                End If

this is my example:

                    If lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString) IsNot Nothing Then
                        lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString()).Selected = True

reportmemberId is a guid filed, so it can't be converted to string to find and display it in the dropdownlist

Maybe I am wrong in the way to do it... May You help me with any indication, please? Thanks a lot.


  #2 (permalink)  
Old January 25th, 2007, 09:30 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi mrco,

How does the drop down for the list of users look like? Do you store the ID of the user as the DataValueField (that is, the value option in the HTML option element) and the user's name as the DataTextField? If that's the case, your code should work.

However, if you use the name for both the text and the value, your code won't work as FindByValue will never be able to find a guid in the list of users.

If this doesn't help, can you post the code to bind the user drop down?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old January 25th, 2007, 10:34 AM
Registered User
 
Join Date: Jan 2007
Location: barcelona, spain, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! but I think this is what I did..
that's the code I think you asked for..:
[u]the dropdownlist</u>
  <td style="height: 24px; width: 282px;"><asp:DropDownList ID="lstReportUser" runat="server" AppendDataBoundItems="True" DataSourceID="odsReportUser" DataTextField="UserName" DataValueField="UserId" Width="180px">
      <asp:ListItem>Please make a selection</asp:ListItem>
  </asp:DropDownList><asp:Label ID="lblReportUser" runat="server" Visible="False" /></td>

[u]the source</u>

<asp:ObjectDataSource ID="odsReportUser" runat="server" SelectMethod="GetUserItems"
    TypeName="ListManager"></asp:ObjectDataSource>


Is it correct?
thanks!


  #4 (permalink)  
Old January 25th, 2007, 12:54 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, that looks fine. However, whether this code works depends on what GetUserItems returns. Since this is not part of the original BugBase application, it's hard for me to see what it returns.

Can you post the code for the method as well?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old January 26th, 2007, 03:54 AM
Registered User
 
Join Date: Jan 2007
Location: barcelona, spain, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sure! That's the code:

[u]Public Class ListManager</u>

Public Shared Function GetUserItems() As DataSet
        Return GetListItems(ListType.aspnet_Users)
    End Function


[u]Public Enum ListType</u>
...
    aspnet_Users
...



[u]Public Shared Function GetListItems</u>(ByVal theListType As ListType) As DataSet
    Dim dataSet As DataSet = New DataSet
    Dim sql As String = ""
    Select Case theListType
...
Case ListType.aspnet_Users
                sql = "sprocUserSelectList"
...

[u]Procedure</u>
ALTER procedure [dbo].[sprocUserSelectList]
AS

SELECT DISTINCT
  UserId,
  UserName
FROM
  aspnet_users
ORDER BY
  UserName

Thanks a lot!! :)



  #6 (permalink)  
Old January 26th, 2007, 04:34 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hmmmm, that all looks as it should.

Are you sure the Users dropdown is databound before you try to set its selected item?

Try setting a break point on the line " If lstReportUser.Items.FindByValue(myTask...." and the put a watch on lstReportUser. Does it have any items at that stage?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old January 26th, 2007, 07:39 AM
Registered User
 
Join Date: Jan 2007
Location: barcelona, spain, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's the info. The debugg doesn't stop at line 2. So it doesn't find the user, does it?

[u]debugg stop</u>
1.If lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString) IsNot Nothing Then
2. lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString()).Selected = True
3. End If


[u]string value</u>
myTask.ReportMemberId.ToString "f833b7b7-bd45-41fa-8cd4-1796a0e06d11" String

[u]aspnet_user file</u>
88d9d34b-8c81-4bba-87a5-cdac69277f30 f833b7b7-bd45-41fa-8cd4-1796a0e06d11 SuperUser superuser NULL False 26/01/2007 11:09:08

[u]
Watch</u>- Items {System.Web.UI.WebControls.ListItemCollection} System.Web.UI.WebControls.ListItemCollection
        Capacity 4 Integer
        Count 1 Integer
        IsReadOnly False Boolean
        IsSynchronized False Boolean
        Item In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. System.Web.UI.WebControls.ListItem
+ SyncRoot {System.Web.UI.WebControls.ListItemCollection} Object


I don't know how to see the lstReportUser items in the watch... sorry...

Thanks!

  #8 (permalink)  
Old January 26th, 2007, 09:09 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You can watch an item by typing it directly in the Watch window. You could, for example enter:

lstReportUser.Items(0) to watch the first item in the list.

However, this is more worrying:

Count 1 Integer

A count of 1 seems to indicate the list hasn't been databound yet. I think the single item in the list is your hard coded "Please select an item" option.

Try calling databind before you try to set the selected item:

lstReportUser.DataBind()If lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString) IsNot Nothing Then
  lstReportUser.Items.FindByValue(myTask.ReportMembe rId.ToString()).Selected = True
End If

Does that help?

Imar
  #9 (permalink)  
Old January 26th, 2007, 09:15 AM
Registered User
 
Join Date: Jan 2007
Location: barcelona, spain, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wonderful!!!!
I inserted the code:

lstReportUser.DataBind()

and now It works!!!

Thanks a lot!!!!! :):)

  #10 (permalink)  
Old January 26th, 2007, 12:23 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're welcome.

Have fun with it....

Imar
---------------------------------------
Imar Spaanjaars
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
Need help: Not able to Assign Value to a Text Area steveleong Classic ASP Professional 3 February 20th, 2008 09:15 PM
Can you Assign a Collection to a Property? MandMD2 Beginning VB 6 2 May 3rd, 2007 05:24 PM
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
How To Assign Value To Session Using Javascript janice.koay Classic ASP Professional 1 May 9th, 2006 12:59 AM
trying to assign a parameter value to 'match=' hottub XSLT 3 April 3rd, 2006 10:18 AM



All times are GMT -4. The time now is 01:21 PM.


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