Binding DropDownList to 2 datasources

Last post 06-16-2008 7:19 PM by bherrok. 2 replies.

Sort Posts:

  • Binding DropDownList to 2 datasources

    06-12-2008, 12:12 AM
    • Loading...
    • bherrok
    • Joined on 02-05-2006, 7:31 PM
    • Melbourne
    • Posts 2

    Hi,

    I have a pretty common issue that unfortunately haven't found any viable solution for.

    In my asp web form, I have a DropDownList inside a repeater control.

    What I'd like to do is populate the DropDownList with a list of options obtained from a SqlDataSource. Currently I'm using the DataBind method for this.

    What I'd like to do then, is bind a column/row from the underlying DataSet (from the repeater control) to the DropDownList.

    The reason for that is, that I'd like when the user changes the selected item in the DropDownList that it would reflect on the DataSet, making use of RowState, GetChanges methods.

    I remember doing this in the old .NET v.1.1 with the CurrencyManager class. But being 4-5 years ago, I can hardly remember how. 

    Thanks in advanced.
     

  • Re: Binding DropDownList to 2 datasources

    06-16-2008, 3:38 AM

    Hi bherrok,

    I guess you want to use the selected value in DropDownList to update the datatable in dataset from Repeater control.

    Have a look at this article about changes in DataTable: http://msdn.microsoft.com/en-us/library/system.data.datarow.rowstate.aspx

    Thanks,

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: Binding DropDownList to 2 datasources

    06-16-2008, 7:19 PM
    Answer
    • Loading...
    • bherrok
    • Joined on 02-05-2006, 7:31 PM
    • Melbourne
    • Posts 2

    Qin Dian Tang Sort-of...

    I think what I wanted to do is not possible or the amount of code outweighs the benefits.

    Reading through some MSDN documentation, the reason this can't be done easily is due to static nature of Web Applications.

    During a postback, the repeater and it's items become unbound and need rebinding. Problem here is that if you have a loader to bind the values, it will try to bind it before "AcceptChanges" in the data sources loosing all the changes made before the post back.

    Understanding the post-back life-cycle of a page can help conditionally binding after accepting changes.

    But as I said above there is too much conditional coding and have opted to go with a class library to store my values.

    Thanks,
    Bernard

     

     

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter