Retrieving SelectedValue from DropDownList

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Retrieving SelectedValue from DropDownList

    I have a few DropDownList controls used for new record entry in the footer of
    a datagrid and I want to limit the options available in one list based on
    what is selected in a previous list; I've seen examples of this where the
    DropDownLists are used in edit mode, but none for data entry mode. The
    footer cell for one column is defined as:

    <FooterTemplate>
    <asp:DropDownList ID="cboWorkflowID" AutoPostBack="true"
    OnSelectedIndexChanged="OnSelectedIndexChanged" DataSource='<%#
    GetWorkflowIDs() %>' Runat="server" DataMember="WorkflowID"
    DataTextField="WorkflowID" />
    </FooterTemplate>

    Setting a breakpoint in the function OnSelectedIndexChanged, I am able to
    pull up the Command Window and see the SelectedValue by typing in:
    ? ( ListControl ) sender. Despite that, I can't for the life of me figure
    out how to programmatically retrieve the value. I've tried virtually every
    permutation of ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID")))
    I can think of, but to no avail. Is there a way?

    Regards,

    Allen Anderson
    AlBruAn Guest

  2. Similar Questions and Discussions

    1. DropDownList.SelectedValue not changing
      I have a DropDownList that is bound and properly filled from my DataSet when the page loads. but when the I try to retrieve any value I always get...
    2. Dynamic DropDownList - Retrieving the controls properties(id, selectedindex, etc...)
      This is being built on dynamicly based on what is returned from my query. Build in the LoadMain() which is called from the Page_Load. I have built...
    3. Persisting DDL.SelectedValue or DDL.SelectedItem.Value without Viewstate
      Use the forms collection. Something like Request.Form("myDDL") in VB. "Paul Aspinall" <paul@nospamaspy.co.uk> wrote in message...
    4. Retrieving Mail using ASP
      You can use dalun's POP3 or IMAP4 webmail, http://www.dalun.com/ftp/pop3.zip http://www.dalun.com/ftp/imap.zip sources included. "Surya"...
    5. Retrieving GUID from DB2 UDB
      Bill Homan <member35043@dbforums.com> wrote in message news:<3203554.1060104571@dbforums.com>... What is actually in the CHAR(16) FOR BIT DATA...
  3. #2

    Default Re: Retrieving SelectedValue from DropDownList

    > ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I can
    > think of, but to no avail. Is there a way?
    You're close, but grab the _grid.Item[x].FindControl where x is the row in
    the grid for the footer.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]



    Brock Allen Guest

  4. #3

    Default Re: Retrieving SelectedValue from DropDownList



    "Brock Allen" wrote:
    > > ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I can
    > > think of, but to no avail. Is there a way?
    >
    > You're close, but grab the _grid.Item[x].FindControl where x is the row in
    > the grid for the footer.
    >
    > -Brock
    > DevelopMentor
    > [url]http://staff.develop.com/ballen[/url]
    >
    >
    Brock,

    I tried (((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID"))) but
    it refuses to work since a count of 9 is returned when asking for
    _grid.Items.Count.

    Allen
    AlBruAn Guest

  5. #4

    Default Re: Retrieving SelectedValue from DropDownList

    Collections are zero-based, so access the position at Count - 1

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > "Brock Allen" wrote:
    >
    >>> ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I can
    >>> think of, but to no avail. Is there a way?
    >>>
    >> You're close, but grab the _grid.Item[x].FindControl where x is the
    >> row in the grid for the footer.
    >>
    >> -Brock
    >> DevelopMentor
    >> [url]http://staff.develop.com/ballen[/url]
    > Brock,
    >
    > I tried (((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID")))
    > but it refuses to work since a count of 9 is returned when asking for
    > _grid.Items.Count.
    >
    > Allen
    >


    Brock Allen Guest

  6. #5

    Default Re: Retrieving SelectedValue from DropDownList

    I'm aware collections are zero-based, that's why I said using 9 as in
    Items[9] wouldn't work. The footer row is currently the 9th row in the grid,
    so your suggestion of using
    ((DropDownList))(_grid.Items[9].FindControl("cboWorkflowID"))) doesn't work.
    Any other idea?

    Thanks!

    Allen

    "Brock Allen" wrote:
    > Collections are zero-based, so access the position at Count - 1
    >
    > -Brock
    > DevelopMentor
    > [url]http://staff.develop.com/ballen[/url]
    >
    >
    >
    > > "Brock Allen" wrote:
    > >
    > >>> ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I can
    > >>> think of, but to no avail. Is there a way?
    > >>>
    > >> You're close, but grab the _grid.Item[x].FindControl where x is the
    > >> row in the grid for the footer.
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> [url]http://staff.develop.com/ballen[/url]
    > > Brock,
    > >
    > > I tried (((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID")))
    > > but it refuses to work since a count of 9 is returned when asking for
    > > _grid.Items.Count.
    > >
    > > Allen
    > >
    >
    >
    >
    >
    AlBruAn Guest

  7. #6

    Default Re: Retrieving SelectedValue from DropDownList

    I'm starting to confuse myself now...LOL. There are currently nine (0
    through 8) rows of data, so that would make the footer row the tenth row.
    Regardless, _grid.Items.Count returns a value of 9 with the last index being
    8, which is to be expected; consequently,
    ((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID"))) can never
    successfully execute, much less return the SelectedValue for that
    DropDownList control. So I'm still stuck without a way of finding what value
    was selected in the control.

    "AlBruAn" wrote:
    > I'm aware collections are zero-based, that's why I said using 9 as in
    > Items[9] wouldn't work. The footer row is currently the 9th row in the grid,
    > so your suggestion of using
    > ((DropDownList))(_grid.Items[9].FindControl("cboWorkflowID"))) doesn't work.
    > Any other idea?
    >
    > Thanks!
    >
    > Allen
    >
    > "Brock Allen" wrote:
    >
    > > Collections are zero-based, so access the position at Count - 1
    > >
    > > -Brock
    > > DevelopMentor
    > > [url]http://staff.develop.com/ballen[/url]
    > >
    > >
    > >
    > > > "Brock Allen" wrote:
    > > >
    > > >>> ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I can
    > > >>> think of, but to no avail. Is there a way?
    > > >>>
    > > >> You're close, but grab the _grid.Item[x].FindControl where x is the
    > > >> row in the grid for the footer.
    > > >>
    > > >> -Brock
    > > >> DevelopMentor
    > > >> [url]http://staff.develop.com/ballen[/url]
    > > > Brock,
    > > >
    > > > I tried (((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID")))
    > > > but it refuses to work since a count of 9 is returned when asking for
    > > > _grid.Items.Count.
    > > >
    > > > Allen
    > > >
    > >
    > >
    > >
    > >
    AlBruAn Guest

  8. #7

    Default Re: Retrieving SelectedValue from DropDownList

    You know what, I think we're mixing topics here. Do you have a DataGrid or
    a DataList? A DataGrid doesn't have a FooterTemplate. If it's a DataList
    then you just directly use the controls you've declared in there.

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > I'm starting to confuse myself now...LOL. There are currently nine (0
    > through 8) rows of data, so that would make the footer row the tenth
    > row. Regardless, _grid.Items.Count returns a value of 9 with the last
    > index being 8, which is to be expected; consequently,
    > ((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID"))) can
    > never successfully execute, much less return the SelectedValue for
    > that DropDownList control. So I'm still stuck without a way of
    > finding what value was selected in the control.
    >
    > "AlBruAn" wrote:
    >
    >> I'm aware collections are zero-based, that's why I said using 9 as in
    >> Items[9] wouldn't work. The footer row is currently the 9th row in
    >> the grid, so your suggestion of using
    >> ((DropDownList))(_grid.Items[9].FindControl("cboWorkflowID")))
    >> doesn't work. Any other idea?
    >>
    >> Thanks!
    >>
    >> Allen
    >>
    >> "Brock Allen" wrote:
    >>
    >>> Collections are zero-based, so access the position at Count - 1
    >>>
    >>> -Brock
    >>> DevelopMentor
    >>> [url]http://staff.develop.com/ballen[/url]
    >>>> "Brock Allen" wrote:
    >>>>
    >>>>>> ((DropDownList)(_grid.Items[0].FindControl("cboWorkflowID"))) I
    >>>>>> can think of, but to no avail. Is there a way?
    >>>>>>
    >>>>> You're close, but grab the _grid.Item[x].FindControl where x is
    >>>>> the row in the grid for the footer.
    >>>>>
    >>>>> -Brock
    >>>>> DevelopMentor
    >>>>> [url]http://staff.develop.com/ballen[/url]
    >>>> Brock,
    >>>>
    >>>> I tried
    >>>> (((DropDownList)(_grid.Items[9].FindControl("cboWorkflowID"))) but
    >>>> it refuses to work since a count of 9 is returned when asking for
    >>>> _grid.Items.Count.
    >>>>
    >>>> Allen
    >>>>


    Brock Allen Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139