Changing the binding of a template column

Discussion in 'ASP .Net Datagrid Control' started by Rob Edwards, Oct 16, 2003.

  1. Rob Edwards

    Rob Edwards Guest

    I have a datagrid that is bound to different datasources.

    The datagrid contains a templated column (dropdown list).

    How do I change the selectedvalue binding to the different datasources? I
    can do this at design time by changing the datasource of the grid, going
    into the databindings popup and adjusted the selected item there... but I
    want to be able to do this in code depending on the dataset selected.

    Thanks in advance.
     
    Rob Edwards, Oct 16, 2003
    #1
    1. Advertising

  2. Hi Rob,

    I have reviewed your issue. Due to the nature of your issue I need to do
    additional research to determine the best way to provide assistance. I will
    contact you as soon as possible.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Oct 17, 2003
    #2
    1. Advertising

  3. Hi Rob,

    If I didn't misunderstand you, you want to change the databinding
    properties on the dropdownlist control that is embedded into a Datagrid as
    a template column.

    If it is the case, we can hook certain event of the datagrid. In such an
    event, we can get an reference to the embedded dropdownlist control and do
    what we want against the control. For example, here is a sample, which
    hooks the ItemCreated event of the datagrid control. In this event, we use
    the FindControl method to locate the dropdownlist control and then bind it
    to an ArrayList object.

    Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemCreated
    Dim DropList As DropDownList =
    CType(e.Item.Cells(0).FindControl("DropDownList1"), DropDownList)
    If (Not DropList Is Nothing) Then
    If Not IsPostBack Then
    Dim myList As New ArrayList()
    myList.Add("Item 1")
    myList.Add("Item 2")
    myList.Add("Item 3")
    myList.Add("Item 4")
    myList.Add("Item 5")
    DropList.DataSource = myList
    DropList.DataBind()
    End If
    End If
    End Sub
    End Class

    Does it answer your question? If I have misunderstood your concern, please
    feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Oct 17, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gary
    Replies:
    1
    Views:
    402
    Natty Gur
    Oct 15, 2003
  2. Jim Hammond

    datagrid template column binding mystery

    Jim Hammond, Nov 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    554
    Jim Hammond
    Nov 24, 2003
  3. Larry R
    Replies:
    1
    Views:
    391
    marss
    Jun 8, 2007
  4. Gary

    changing the template column's position ?

    Gary, Oct 14, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    222
    Mike Moore [MSFT]
    Oct 15, 2003
  5. raghunath
    Replies:
    2
    Views:
    328
    Kubuli John
    Apr 29, 2004
Loading...

Share This Page