Here's my code. I can't get the ddls to populate when the pages loads. I've only got two built in the code so far, but we want to be able to support 5-10 when the code goes live. I know the sprocs work, since since I tried using cache for the datasets, the ddls wouldn't populate.
The dropdownlists that don't populate are:
KSddlNewName
KSddlNewName2
KSddlNewP3ResCode
KSddlNewP3ResCode2
Imports System
Imports System.Collections
Imports System.DBNull
Imports System.Data.SqlClient
Imports System.CLSCompliantAttribute
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class AddMulitpleResources
Inherits System.Web.UI.Page
Dim DSNewName As DataSet
Dim DSNewP3ResCode As DataSet
Public arrFY As String() = {"05", "06", "07", "08", _
"09", "10", "11", "12", "13", "14", "15", "16", "17", _
"18", "19", "20"}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
'Make SQL Statement to populate New Name ddl
Dim strSQLNewName As String = "usp_SARes_KSddlNewName"
sCon.Open()
Dim cmd As New SqlCommand(strSQLNewName, sCon)
cmd.CommandType = CommandType.StoredProcedure
Dim DANewName As New SqlDataAdapter
DANewName.SelectCommand = cmd
Dim DSNewName As New DataSet
DANewName.Fill(DSNewName)
'************************************
If Cache("DSNewName") Is Nothing Then
CacheDS("DSNewname", DSNewName)
End If
'Make SQL Statement to populate the second ddl, KSddlNewP3ResourceCode
Dim strSQLNewP3 As String = "usp_SARes_KSddlNewP3ResourceCode"
Dim cmdP3 As New SqlCommand(strSQLNewP3, sCon)
cmdP3.CommandType = CommandType.StoredProcedure
Dim DA As New SqlDataAdapter
DA.SelectCommand = cmdP3
Dim DSNewP3ResCode As New DataSet
DA.Fill(DSNewP3ResCode)
If Cache("DSNewP3ResCode") Is Nothing Then
CacheDS("DSNewP3ResCode", DSNewP3ResCode)
End If
'**************************************
sCon.Close()
Call Build_KSddlNewName()
Call buildKSddlNewP3ResourceCode()
Call BuildFYddls()
End If
End Sub
Sub CacheDS(ByVal Name As String, ByVal Item As Object)
Cache.Add(Name, Item, Nothing, DateTime.MaxValue, System.TimeSpan.FromMinutes(40), _
Caching.CacheItemPriority.Default, Nothing)
End Sub
Sub BuildFYddls()
KSFYddl.DataSource = arrFY
KSFYddl.DataBind()
KSFY2ddl.DataSource = arrFY
KSFY2ddl.DataBind()
End Sub
Public Sub Build_KSddlNewName()
KSddlNewName.DataSource = DSNewName
KSddlNewName.DataTextField = "Expr4"
KSddlNewName.DataValueField = "ZNumber"
KSddlNewName.DataBind()
KSddlNewName.Items.Insert(0, "")
KSddlNewName2.DataSource = DSNewName
KSddlNewName2.DataTextField = "Expr4"
KSddlNewName2.DataValueField = "ZNumber"
KSddlNewName2.DataBind()
KSddlNewName2.Items.Insert(0, "")
'Make SQL Statement to populate the third ddl, KSddlNewRateType
End Sub
Public Sub buildKSddlNewP3ResourceCode()
KSddlNewP3ResourceCode.DataSource = DSNewP3ResCode
KSddlNewP3ResourceCode.DataTextField = "Expr1"
KSddlNewP3ResourceCode.DataValueField = "RES"
KSddlNewP3ResourceCode.DataBind()
KSddlNewP3ResourceCode.Items.Insert(0, "")
KSddlNewRateType.SelectedIndex = 1 'Select A for the Rate Typ
KSddlNewP3ResourceCode2.DataSource = DSNewP3ResCode
KSddlNewP3ResourceCode2.DataTextField = "Expr1"
KSddlNewP3ResourceCode2.DataValueField = "RES"
KSddlNewP3ResourceCode2.DataBind()
KSddlNewP3ResourceCode2.Items.Insert(0, "")
KSddlNewRateType2.SelectedIndex = 1 'Select A for the Rate Typ
End Sub
End Class
The dropdownlists that don't populate are:
KSddlNewName
KSddlNewName2
KSddlNewP3ResCode
KSddlNewP3ResCode2
Imports System
Imports System.Collections
Imports System.DBNull
Imports System.Data.SqlClient
Imports System.CLSCompliantAttribute
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Configuration
Public Class AddMulitpleResources
Inherits System.Web.UI.Page
Dim DSNewName As DataSet
Dim DSNewP3ResCode As DataSet
Public arrFY As String() = {"05", "06", "07", "08", _
"09", "10", "11", "12", "13", "14", "15", "16", "17", _
"18", "19", "20"}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
'Make SQL Statement to populate New Name ddl
Dim strSQLNewName As String = "usp_SARes_KSddlNewName"
sCon.Open()
Dim cmd As New SqlCommand(strSQLNewName, sCon)
cmd.CommandType = CommandType.StoredProcedure
Dim DANewName As New SqlDataAdapter
DANewName.SelectCommand = cmd
Dim DSNewName As New DataSet
DANewName.Fill(DSNewName)
'************************************
If Cache("DSNewName") Is Nothing Then
CacheDS("DSNewname", DSNewName)
End If
'Make SQL Statement to populate the second ddl, KSddlNewP3ResourceCode
Dim strSQLNewP3 As String = "usp_SARes_KSddlNewP3ResourceCode"
Dim cmdP3 As New SqlCommand(strSQLNewP3, sCon)
cmdP3.CommandType = CommandType.StoredProcedure
Dim DA As New SqlDataAdapter
DA.SelectCommand = cmdP3
Dim DSNewP3ResCode As New DataSet
DA.Fill(DSNewP3ResCode)
If Cache("DSNewP3ResCode") Is Nothing Then
CacheDS("DSNewP3ResCode", DSNewP3ResCode)
End If
'**************************************
sCon.Close()
Call Build_KSddlNewName()
Call buildKSddlNewP3ResourceCode()
Call BuildFYddls()
End If
End Sub
Sub CacheDS(ByVal Name As String, ByVal Item As Object)
Cache.Add(Name, Item, Nothing, DateTime.MaxValue, System.TimeSpan.FromMinutes(40), _
Caching.CacheItemPriority.Default, Nothing)
End Sub
Sub BuildFYddls()
KSFYddl.DataSource = arrFY
KSFYddl.DataBind()
KSFY2ddl.DataSource = arrFY
KSFY2ddl.DataBind()
End Sub
Public Sub Build_KSddlNewName()
KSddlNewName.DataSource = DSNewName
KSddlNewName.DataTextField = "Expr4"
KSddlNewName.DataValueField = "ZNumber"
KSddlNewName.DataBind()
KSddlNewName.Items.Insert(0, "")
KSddlNewName2.DataSource = DSNewName
KSddlNewName2.DataTextField = "Expr4"
KSddlNewName2.DataValueField = "ZNumber"
KSddlNewName2.DataBind()
KSddlNewName2.Items.Insert(0, "")
'Make SQL Statement to populate the third ddl, KSddlNewRateType
End Sub
Public Sub buildKSddlNewP3ResourceCode()
KSddlNewP3ResourceCode.DataSource = DSNewP3ResCode
KSddlNewP3ResourceCode.DataTextField = "Expr1"
KSddlNewP3ResourceCode.DataValueField = "RES"
KSddlNewP3ResourceCode.DataBind()
KSddlNewP3ResourceCode.Items.Insert(0, "")
KSddlNewRateType.SelectedIndex = 1 'Select A for the Rate Typ
KSddlNewP3ResourceCode2.DataSource = DSNewP3ResCode
KSddlNewP3ResourceCode2.DataTextField = "Expr1"
KSddlNewP3ResourceCode2.DataValueField = "RES"
KSddlNewP3ResourceCode2.DataBind()
KSddlNewP3ResourceCode2.Items.Insert(0, "")
KSddlNewRateType2.SelectedIndex = 1 'Select A for the Rate Typ
End Sub
End Class