hmmm....how would I do that??
Main Topics
Browse All TopicsHi Folks.
I'm attempting to fill a form with Client data from "tblClient". Several of these fields are listboxes, which are filled using stored procedures and are calling values from other tables.
Works fine if I don't try to put in the listboxes.
Here is the error:
BC30451: Name 'ClientOriginAreaID' is not declared.
ClientOriginAreaID is the id of a listbox.
Any ideas why it would want me to declare it?? When i do, it still doesn't work...."not set to an instance of an obeject" errors.
Here is to code
**************************
<%@ Page Explicit="FALSE" Language="VB" Debug="True" %>
<%@ Register TagPrefix="ATH" TagName="Header" Src="../_includes/header.a
<%@ Register TagPrefix="ATH" TagName="LeftSide" Src="../_includes/leftside
<%@ import Namespace="System.Data.Sql
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Ole
<script runat="server">
dim Connect2 AS OLEDBConnection = New OLEDBConnection
dim connectString2 As String
dim connect as SQLConnection = New SQLConnection
dim ConnectString As String
Dim RegionID AS Integer
Dim FirstName as String
Dim LastName as String
Dim dtmDate As DateTime = DateTime.Now()
Sub Page_load(sender as Object, e as EventArgs)
If session("Role") = "" then
Session("StartPage")= Request.ServerVariables("S
response.redirect("/Access
end if
RegionID = Session("RegionID")
Dim ID AS Integer
ID = request.querystring("ID")
ConnectString="Server=myse
connectstring2="Provider=S
Connect.ConnectionString = ConnectString
Connect2.ConnectionString=
If Not IsPostBack then
connect2.open
Dim objCmd as New OleDbCommand("sp_listareas
objCmd.CommandType = CommandType.StoredProcedur
Dim objDR as OleDbDataReader
objDR = objCmd.ExecuteReader()
'Databind the DataReader to the listbox Web control
ClientOriginAreaID.DataSou
ClientOriginAreaID.DataBin
connect2.close
connect2.open
Dim objDR1 as OleDbDataReader
objDR1 = objCmd.ExecuteReader()
Client1stChoiceAreaID.Data
Client1stChoiceAreaID.Data
connect2.close
connect2.open
Dim objDR2 as OleDbDataReader
objDR2 = objCmd.ExecuteReader()
Client2ndChoiceAreaID.Data
Client2ndChoiceAreaID.Data
connect2.close
connect2.open
Dim reasonCmd as New OleDbCommand("sp_listreaso
reasonCmd.CommandType = CommandType.StoredProcedur
Dim reasonDR as OleDbDataReader
reasonDR = reasonCmd.ExecuteReader()
'Databind the DataReader to the listbox Web control
ClientReason1ID.DataSource
ClientReason1ID.DataBind()
connect2.close
connect2.open
Dim reasonDR1 as OleDbDataReader
reasonDR1 = reasonCmd.ExecuteReader()
ClientReason2ID.DataSource
ClientReason2ID.DataBind()
connect2.close
connect2.open
Dim typeCmd as New OleDbCommand("sp_listresty
typeCmd.CommandType = CommandType.StoredProcedur
Dim typeDR as OleDbDataReader
typeDR = typeCmd.ExecuteReader()
'Databind the DataReader to the listbox Web control
Client1stChoiceResidenceTy
Client1stChoiceResidenceTy
connect2.close
connect2.open
Dim typeDR1 as OleDbDataReader
typeDR1 = typeCmd.ExecuteReader()
Client2ndChoiceResidenceTy
Client2ndChoiceResidenceTy
BindDataGrid(ID)
end if
End Sub
Sub BindDataGrid(ID AS Integer)
dim GetContactCommand AS OleDBcommand= New OleDBCommand("Select * FROM tblclients WHERE tblClients.ApplicationID="
Dim Adapter AS OleDBDataAdapter = new OleDBDataAdapter
Adapter.Selectcommand = getContactCommand
Adapter.SelectCommand.Conn
dim ContactDS AS DataSet = New DataSet
Adapter.Fill(ContactDS, "Contact")
ContactGrid.DataSource = ContactDS
Page.dataBind()
End Sub
</script>
<html>
<head>
<title>Edit Client Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<meta id="GENERATOR" content="Microsoft FrontPage 6.0" />
<meta id="ProgId" content="FrontPage.Editor.
<link href="../_includes/master.
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<table style="BORDER-COLLAPSE: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td width="100%">
<ATH:header id="UserControl1" runat="server"></ATH:heade
</td>
</tr>
</tbody>
</table>
<table style="BORDER-COLLAPSE: collapse" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td class="left" valign="top" width="150">
<table style="BORDER-COLLAPSE: collapse" cellpadding="0" width="150" border="0">
<tbody>
<tr>
<td>
<ATH:Leftside id="UserControl2" runat="server"></ATH:Lefts
</td>
</tr>
</tbody>
</table>
</td>
<td class="textarea" valign="top" width="100%">
<form runat="server">
<ASP:DataGrid id="ContactGrid" EnableViewState="True" AutoGenerateColumns="False
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<p>
Application Date:
<asp:TextBox Runat="Server" id="ClientApplicationDate"
Date Last Updated: <asp:T
</p>
<p>
First Name: <asp:TextBox Runat="Server" id="ClientFirstName" text='<%#Container.DataIte
Last Name:<asp:TextBox Runat="Server" id="ClientLastName" text='<%#Container.DataIte
&n
<asp:checkbox Runat="server" id="ClientNOPrivates" checked='<%#(DataBinder.Ev
</p><p>Date of Birth: <asp:TextBox Runat="Server" id="ClientDOB" size="10" text='<%#format(Container.
</p><p>Number in Family:
<asp:TextBox Runat="Server" id="ClientNumberInFamily" text='<%#Container.DataIte
<asp:TextBox Runat="Server" id="ClientInShelter" text='<%#Container.DataIte
</p><p>Children Under 6: <asp:TextBox Runat="Server" id="ClientChildrenUnder6" text='<%#Container.DataIte
Children 7-12: <asp:TextBox Runat="Server" id="ClientChildrenUnder12"
Children 13-21: <asp:TextBox Runat="Server" id="ClientChildrenUnder21"
Total Children: <asp:TextBo
</p><p>Other Family Info:<asp:TextBox Runat="Server" id="ClientOtherFamilyInfo"
Spousal D.O.B.
<asp:TextBox Runat="Server" id="ClientSpousalDOB" size="20" text='<%#format(Container.
<asp:TextBox Runat="Server" id="ClientPhone" text='<%#Container.DataIte
</p><P>Primary Reason for Leaving:<asp:listbox Runat="server" rows="1" id="ClientReason1ID" DataTextField="ReasonforLe
</asp:listbox><p>Secondary
<p>First Choice Area: <asp:list
</asp:listbox>
First Choice Residence: <asp
</asp:listbox>Second Choice Area: <asp:listbox Runat="server" rows="1" id="Client2ndChoiceAreaID"
</asp:listbox></p><P><XXXX
</asp:listbox><P>Date Needed: <asp:TextBox Runat="Server" id="ClientNeedDate" text='<%#Container.DataIte
Immediately?
<asp:checkbox Runat="server" id="ClientImmediateNeed" checked='<%#(Databinder.ev
<asp:checkbox Runat="server" id="ClientNotice" checked='<%#(DataBinder.ev
Top Price: <asp:Tex
Ideal Maximum Rent:<asp:TextBox Runat="Server" id="ClientIdealRent" size="6" disabled="disabled" text='<%#Container.DataIte
</p><p></p><p>Has 1st & Last? <input type="checkbox" id="Client1stLast" value="1" />
References?<asp:checkbox Runat="server" id="ClientHaveRefs" checked='<%#(Databinder.ev
</p><p>Where From?
<asp:listbox size="1" id="ClientOriginAreaID" Rows="1" DataTextField="AreaName" DataValueField="AreaID" runat="server" /></asp:listbox></p><p>Ris
Children Homeless: <asp:TextBo
Number Affected:<asp:TextBox Runat="Server" id="ClientNumberAffected" text='<%#Container.DataIte
</p><p>Employed:<asp:TextB
</p><p><b>Job Sector:</b> Trade&nbs
Professional<a
Service:
BlueMtn<asp:TextBox Runat="Server" id="ClientBM" text='<%#Container.DataIte
Other <asp:TextBox Runat="Server" id="ClientJobSvc" text='<%#Container.DataIte
</p><p><b>Manufacturing:</
LOF <asp:TextBo
GY <asp:TextBox
RLAlcoa<asp:TextBox Runat="Server" id="ClientRLAlcoa" text='<%#Container.DataIte
Other<asp:TextBox Runat="Server" id="ClientJobMan" text='<%#Container.DataIte
</p><p>Pension/Benefits&nb
Disability <asp
EI/SickPay<asp:TextB
Work/Family Benefits <asp:TextBox
<br />Child Support <asp:TextBox Runat="Server" id="ClientChildSupport" text='<%#Container.DataIte
Child Aid <asp:TextBox Runat="Server" id="ClientChildAid" text='<%#Container.DataIte
Child Tax <asp:TextBox Runat="Server" id="ClientChildTax" text='<%#Container.DataIte
Ont Works?<asp:TextBox Runat="Server" id="ClientOntWeeks" text='<%#Container.DataIte
</p><p>Comments:
</p><p></p><asp:textbox runat="server" id="ClientComments" textmode="multiline" text='<%#Container.DataIte
Unit Housed? <asp:TextBox Runat="Server" id="ClientHousebyUnit" text='<%#Container.DataIte
Lost Contact<asp:TextBox Runat="Server" id="ClientLostContact" columns="2" text='<%#Container.DataIte
Flex Units<asp:TextBox Runat="Server" id="ClientFlexUnits" columns="2" text='<%#Container.DataIte
Stayed in Same: <asp:TextBox Runat="Server" id="ClientStayHome" text='<%#Container.DataIte
<br />Date Housed?<asp:TextBox Runat="Server" id="HouseDate" size="18" text='<%#format(Container.
</p><p><input type="submit" value="Make Changes to this Client" id="Edit" />
<input type="reset" value="Clear All Fields" id="Reset" />
</p></ItemTemplate></asp:T
</
</td>
</tr>
</tbody>
</table>
</body>
</html>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I suspect that this is because your page does not contain a declared object ID'd as "ClientOriginAreaID".
The ClientOriginAreaID object you do have is declared within your DataGrid's TemplateColumn's ItemTemplate, which means that there will be one of these added to the DataGrid for each DataRow within the DataGrid's data source.
You could try creating an ItemDataBound event handler for your DataGrid object, and moving your ClientOriginAreaID-related
DataGrid.ItemDataBound event: http://msdn.microsoft.com/
Basically, what he's saying is something that looks like this:
public Sub ContactGrid_OnItemDataBoun
ByVal e As System.Web.UI.WebControls.
Dim rec As DataRowView
rec = e.Item.DataItem
'Make sure that you have the data.
If Not IsDBNull(rec) Then
Dim l1 As ListBox
l1 = e.Item.FindControl("Client
Dim objCmd as New OleDbCommand("sp_listareas
objCmd.CommandType = CommandType.StoredProcedur
Dim objDR as OleDbDataReader
objDR = objCmd.ExecuteReader()
'Databind the DataReader to the listbox Web control
l1.DataSource = objDR
l1.DataBind()
connect2.close
End If
End Sub
And BDW Thogek no problem :) I share!
Good Luck
Hey all!
I've got it wokring...thanks for you help.
Went a slightly different route:
'*************************
Private Function BindState()
Dim myCommand As SqlCommand = New SqlCommand("sp_listareas_d
myCommand.CommandType = CommandType.StoredProcedur
'myCommand.Parameters.Add(
Connect.Open()
Return myCommand.ExecuteReader(Co
End Function
Dim strCurrentState as Integer
Private Sub DG_ItemDataBound(s as object, e as DataGridItemEventArgs)
Dim cboStateTemp As DropDownList = CType(e.Item.FindControl("
Dim strTemp as String = cboStateTemp.SelectedItem.
Dim myDropDown as DropDownList
myDropDown = Ctype(e.Item.FindControl("
myDropDown.SelectedIndex = myDropDown.Items.IndexOf(m
End Sub
'*************************
And then used the dropdownlist like this:
<asp:DropDownList
id="ClientOriginAreaID"
DataSource="<%# BindState() %>"
DataTextField="AreaName"
DataTextValue="AreaID"
runat="server"/>
Works great.,.....now, if I can only get the Selected Index to be the value found in the TblClients......I can either open that in another question or maybe you have some ideas??
Thanks!
Business Accounts
Answer for Membership
by: dabitbolPosted on 2004-10-04 at 10:39:08ID: 12219413
The problem is that your control resides inside your DataGrid. So your page doesn't see it.
You are going to have to get your collection from a function.