Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2d Database queries, what works best? (vb.net)

    Seems as though things have been coming along nicely in my asp.net endeavors until this point-- I have one or two last pages to construct which are so far out of reach of my asp.net skills. I know exactly *how* I want to do it, I just don't know how I can get the message across to asp.net...
    If I were to do so in php, it would probably take 20 mins tops <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    So here's the scoop:
    In the site I am doing, a "conference" has many "tracks" (or categories), to which one user must be assigned as a "track chair".
    The page I am constructing will let an administrator designate who is "track chair" of which particular "track" for which particular "conference".
    (conferences do not necessarily contain all tracks, nor do users sign up for the same tracks in all conferences)

    The funky part is that users express an interest in becoming a track chair on a per-conference basis. So, the list of users which the administrator chooses from is dictated by who has "signed up" or put their name on the list.

    In my head, the page would look something like this:
    ------------
    Welcome, administrator...
    You are assigning track chairs for XYZ conference on the 20th of June.
    Tracks in XYZ conference are as follows:

    Track A: Underwater basketweaving (Dropdown of users who have expressed an inerest in becoming the chair of the Underwater Basketweaving track in XYZ conference)
    Track B: Stupid Human Tricks (Dropdown of users....who want to be chairs for this track)
    Track C: Advanced Calculus (Dropdown of users...)
    [....]

    [submit]
    ----------
    Holy recusion, batman! Have I lost my mind or is it reasonable to expect that I can do such a thing... my other concern is how to process the data when it gets submitted... but I have to worry about generating the form first of all.

    I don't exactly know what type of control I should be looking at using either... I have come to find out that the datagrid hasn't done too badly so far, but perhaps something more generic like a repeater would be the best bet?

    I would probably be able to figure out a way to do them one at a time, but that is more time consuming for the end user, of course. Any ideas on what type of an approach to take on this one?

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2d Database queries, what works best? (vb.net)

    Hi Lancer,

    Your page mockup below sounds spot on. You're also on the right track in that you should probably use something more lightweight than the datagrid - probably a repeater would do the trick here.

    The way I would go about populating the dropdowns is by using the OnDataBound event of the Repeater. For each item that gets databaound, the event will fire. You'll want to place a hidden label in the ItemTemplate portion of the repeater that is bound to the ConferenceId. In the OnDataBound event handler, you'll want to read the value of the label then populate the dropdown (with chair volunteers) based on the ConferenceId.

    My information may not have the specifics to match your project, but the overall direction is one of the best ways to do it.

    Hope this helps!

  3. #3
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2d Database queries, what works best? (vb.net)

    Hey, works like a charm, I now have the form that pulls out the correct choices from the database for each line... but now I just need to worry about processing the form once it is posted back... do I do this sort of thing under the same OnDataBound event? Otherwise, I am not quite sure how one would iterate through the repeater or find the necessary values...
    Hope I am on the right track? Thanks for your help.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2d Database queries, what works best? (vb.net)

    That depends on the data you're collecting from the form post.

    If you're collecting general data that applies to the entire page, you should use the server-side OnClick event of an ASP:Button object (or LinkButton or ImageButton - same thing).

    Simply add the button object to the form using the designer and double-click the button to automatically create the code for the click event of the button. Then you can easily read the user-entered value of the object in question using <YourObject>.Text or <YourObject>.SelectedValue (depending on object type).

    If you're collecting data related to a data-bound control (repeater, DataList or DataGrid), it's a little more complicated. Assuming you're editing a row of the repeated control, you'll need to use a submit control in that specific row. When the itemCommand event of the data control is fired, you can capture the specific row from the arguments of the firing control.

    To quickly get up to speed on data controls (particularly the DataGrid), check out this article from 4GuysFromRolla.

    Hope this helps!

  5. #5
    Lounger
    Join Date
    May 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2d Database queries, what works best? (vb.net)

    Well, I am using a repeater control, and providing a dropdown menu at the end of each row, which is not used to edit any information in the repeater, but rather just to make some new entries in a different db table... So as you said, using the OnClick event of my submit button would put me in the right scenario to have access to the form data... then I could probably do a loop through the repeater: "for each item in xyzRepeater.Items" ?
    I think I will give the foreach loop a shot... thanks for your help again [img]/forums/images/smilies/smile.gif[/img]

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2d Database queries, what works best? (vb.net)

    It sounds like you're in the right ballpark. I've used a similar technique to muscle the datagrid into providing the needed functionality.

    You'll want to do something like: For Each <youvariable> as DataItem in Repeater.Items

    (pardon my rusty VB syntax - I've been using only C# for a couple of years...)

    That way, you can use the DataItem class, which will allow you to access each row in the repeater (i.e. Item.FindControl), etc.

    Hope this helps!

Posting Permissions

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