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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Datagrid dropdownlist, populated from Access database. [modified]

Datagrid dropdownlist, populated from Access database. [modified]

Scheduled Pinned Locked Moved Visual Basic
databasehelpsysadmindockerannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robw1888
    wrote on last edited by
    #1

    Hi all, First of all I'll apologise in advance! I'm very new to this and have been trying to learn through books and what I can pick up on the net so I'm hoping someone can help me understand where I'm going wrong with the following... I've set up a datagrid which works perfectly when I use textboxes, however I'm trying to limit user choice by adding dropdownlists to the datagrid. I get as far as clicking to edit the field and get the following error: --------------------------- System.IndexOutOfRangeException: StatusID Source Error: Line 345: Line 346: Line 347: Status <%# Container.DataItem("Status") %> and VB code is : to populate the dataset ('Dim DS as DataSet = New DataSet()' declared globally) ... Function GetStatus() as DataSet Dim DBConn as OleDbConnection Dim DBCommand as OleDbDataAdapter DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/Auto_log.mdb") & ";") DBCommand = New OleDbDataAdapter("SELECT StatusID, Status from Status ORDER BY Status", DBConn) DBCommand.Fill(DS, "Status") DBConn.Close() Return DS End Function ---------------- to get selected index - Function GetSelectedIndex(ByVal StatusID As String) As Integer 'Loop through the DataSet DS Dim iLoop As Integer Dim DT As DataTable = DS.Tables("Status") For iLoop = 0 To DT.Rows.Count - 1 If StatusID = DT.Rows(iLoop)("StatusID").ToString Then Return iLoop End If Next iLoop End Function ----------- ... & to update the database (cut to show coding related to ddl)- Sub dg_Update(s As Object, e As DataGridCommandEventArgs)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

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