Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

BikerMonkey

@BikerMonkey
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Binding combox in gridview with selected value of another comboBox
    B BikerMonkey

    Hi all, I hope I got the right forum... I can do what the subject states when the comboBox or DropDown is NOT in a gridview, as in the code below which populates the room DDL with the value that was selected in the building DDL

    Protected Sub DDLbuilding_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLbuilding.SelectedIndexChanged
    'Create DataTable
    Dim dtRooms As New DataTable() ' - Room Numbers
    dtRooms.Columns.Add("Room", Type.GetType("System.String"))

        'Get Buildings for this campus
        RoomTable = RoomAdapter.GetRooms(DDLbuilding.SelectedValue)
    
        'Fill DataTable
        For Each RoomRow In RoomTable
            dtRooms.Rows.Add()
            dtRooms.Rows(dtRooms.Rows.Count - 1)("Room") = RoomRow.Room
        Next
    
        'bind DDLroom to datatable
        DDLroom.DataSource = dtRooms
        DDLroom.DataBind()
    End Sub
    

    but when the comboBox or DDL is in a gridview it throws the error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control". Here's what I have so far for the gridview comboBox

    Protected Sub cbEQName_SelectedIndexChanged(sender As Object, e As EventArgs)

        'Get row index of selected comboBox
        Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
        Dim index As Integer = gvRow.RowIndex
    
        'Get selected value of selected comboBox
        EQname = TryCast(GVnewEquipment.Rows(index).FindControl("cbEQname"), AjaxControlToolkit.ComboBox).Text
    
        'Get new values of next comboBox from selected value of selected comboBox
        EquipmentTable = EquipmentAdapter.GetMfg(EQname)
    
        'Create DataTable
        Dim dtMfgs As New DataTable() ' - mfgs that are used by Equiptment name
        dtMfgs.Columns.Add("mfg", Type.GetType("System.String"))
    
        'Fill DataTable
        For Each EquipmentRow In EquipmentTable
            dtMfgs.Rows.Add()
            dtMfgs.Rows(dtMfgs.Rows.Count - 1)("mfg") = EquipmentRow.mfg
        Next
    
        'create ComboBox which will represent GVnewQuipment cbMfg comboBox
        Dim CB = DirectCast(GVnewEquipment.Rows(index).FindControl("cbMfg"), AjaxControlToolkit.ComboBox)
    
        'bind cbMfg to datatable
        CB.DataSource = dtMfgs
        CB.DataBind()
    
    End Sub
    

    Any and help is greatly appreciated!!

    Lee

    ASP.NET help database wpf wcf xml

  • Open Letter to All IT Recruiting Agencies
    B BikerMonkey

    John, Let me make sure I understand what your issue is.... "Your getting too many offers for work". Did I read that right? Let me know... Lee

    The Lounge career regex help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups