Solved

BC30451:  item not declared?

Posted on 2004-10-04
23
1,091 Views
Last Modified: 2007-11-27
Hi 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.ascx" %>
<%@ Register TagPrefix="ATH" TagName="LeftSide" Src="../_includes/leftside.ascx" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<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("SCRIPT_NAME")
                response.redirect("/AccessToHousing/login.aspx")
            end if
   
            RegionID = Session("RegionID")
   
            Dim ID AS Integer
   
            ID = request.querystring("ID")
   
            ConnectString="Server=myserver; UID=mylogin; PWD=mylogin; DATABASE=accesstohousing;"
            connectstring2="Provider=SQLOLEDB;Server=myserver; UID=mylogin; PWD=mylogin; DATABASE=accesstohousing;"
   
            Connect.ConnectionString = ConnectString
            Connect2.ConnectionString= ConnectString2
   
            If Not IsPostBack then
                      connect2.open
                  Dim objCmd as New OleDbCommand("sp_listareas_display", Connect2)
                objCmd.CommandType = CommandType.StoredProcedure
              Dim objDR as OleDbDataReader
               objDR = objCmd.ExecuteReader()
   
   
               'Databind the DataReader to the listbox Web control
               
               ClientOriginAreaID.DataSource = objDR
                ClientOriginAreaID.DataBind()
                connect2.close
                connect2.open
                Dim objDR1 as OleDbDataReader
                   objDR1 = objCmd.ExecuteReader()
     
                  Client1stChoiceAreaID.DataSource = objDR1
                  Client1stChoiceAreaID.DataBind()
                connect2.close
               
                connect2.open
                Dim objDR2 as OleDbDataReader
                objDR2 = objCmd.ExecuteReader()
                     
           
                  Client2ndChoiceAreaID.DataSource = objDR2
                  Client2ndChoiceAreaID.DataBind()
                connect2.close
               
                connect2.open
              Dim reasonCmd as New OleDbCommand("sp_listreason_display", Connect2)
                reasonCmd.CommandType = CommandType.StoredProcedure
                  Dim reasonDR as OleDbDataReader
                  reasonDR = reasonCmd.ExecuteReader()

              'Databind the DataReader to the listbox Web control
                  ClientReason1ID.DataSource = reasonDR
                  ClientReason1ID.DataBind()
                          connect2.close
                connect2.open
                Dim reasonDR1 as OleDbDataReader
                  reasonDR1 = reasonCmd.ExecuteReader()

                  ClientReason2ID.DataSource = reasonDR1
                  ClientReason2ID.DataBind()
                          connect2.close
                connect2.open
                Dim typeCmd as New OleDbCommand("sp_listrestype_display", Connect2)
                typeCmd.CommandType = CommandType.StoredProcedure
                  Dim typeDR as OleDbDataReader
                  typeDR = typeCmd.ExecuteReader()
   
              'Databind the DataReader to the listbox Web control
                 Client1stChoiceResidenceType.DataSource = typeDR
                  Client1stChoiceResidenceType.DataBind()
                          connect2.close
                connect2.open
                Dim typeDR1 as OleDbDataReader
                  typeDR1 = typeCmd.ExecuteReader()

                  Client2ndChoiceResidenceType.DataSource = typeDR1
                 Client2ndChoiceResidenceType.DataBind()
   
                BindDataGrid(ID)
            end if
   
   
    End Sub
   
    Sub BindDataGrid(ID AS Integer)
   
            dim GetContactCommand AS OleDBcommand= New OleDBCommand("Select * FROM tblclients WHERE tblClients.ApplicationID="& ID, Connect2)
   
            Dim Adapter AS OleDBDataAdapter = new OleDBDataAdapter
            Adapter.Selectcommand = getContactCommand
            Adapter.SelectCommand.Connection.Open
   
            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.Document" />
    <link href="../_includes/master.css" type="text/css" rel="stylesheet" />
</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:header>
                </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:Leftside>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
                <td class="textarea" valign="top" width="100%">
                    <form runat="server">
                        <ASP:DataGrid id="ContactGrid" EnableViewState="True" AutoGenerateColumns="False" Runat="server">
                            <Columns>
                                <asp:TemplateColumn>
                                    <ItemTemplate>
                                        <p>
                                            Application Date:&nbsp;
                                            <asp:TextBox Runat="Server" id="ClientApplicationDate" columns="10" text='<%# format(Container.DataItem( "ClientApplicationDate" ), "d")%>' Enabled="False"></asp:TextBox>
                                            Date Last Updated:&nbsp;&nbsp;<asp:Textbox id="ClientUpdated" Runat="server" Text='<%#format(Container.DataItem("ClientUpdated" ),"d")%>' Enabled="False"></asp:textbox>
                                        </p>
                                        <p>
                                            First Name:&nbsp;<asp:TextBox Runat="Server" id="ClientFirstName" text='<%#Container.DataItem("ClientFirstName")%>' size="20"></asp:textbox>
                                            &nbsp;Last Name:<asp:TextBox Runat="Server" id="ClientLastName" text='<%#Container.DataItem("ClientLastName")%>' size="20"></asp:textbox>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <asp:checkbox Runat="server" id="ClientNOPrivates" checked='<%#(DataBinder.Eval(Container.DataItem, "ClientNoPrivates") = "True")%>'></ASP:CHECKBOX><font color="#FF0099">Do NOT give privates!</font>
                                        </p><p>Date of Birth:&nbsp;<asp:TextBox Runat="Server" id="ClientDOB" size="10" text='<%#format(Container.DataItem("ClientDOB"), "d")%>'></asp:textbox>
                                        </p><p>Number in Family:&nbsp;
                                            <asp:TextBox Runat="Server" id="ClientNumberInFamily" text='<%#Container.DataItem("ClientNumberInFamily")%>' columns="2"></asp:textbox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In A Shelter Now?&nbsp;
                                            <asp:TextBox Runat="Server" id="ClientInShelter" text='<%#Container.DataItem("ClientInShelter")%>' columns="2"></asp:textbox>&nbsp;&nbsp; Release Info Ok?&nbsp;&amp;<asp:checkbox id="ClientPermission" runat="server" Checked='<%#(DataBinder.Eval(Container.DataItem,"ClientPermission")="Y") %>'></ASP:CHECKBOX>
                                        </p><p>Children Under 6:&nbsp;<asp:TextBox Runat="Server" id="ClientChildrenUnder6" text='<%#Container.DataItem("ClientChildrenUnder6")%>' columns="2"></asp:textbox>
                                            Children 7-12:&nbsp;<asp:TextBox Runat="Server" id="ClientChildrenUnder12" columns="2" text='<%#Container.DataItem("ClientChildrenUnder12")%>'></asp:textbox>
                                            &nbsp; Children 13-21:&nbsp;<asp:TextBox Runat="Server" id="ClientChildrenUnder21" columns="2" text='<%#Container.DataItem("ClientChildrenUnder21")%>'></asp:textbox>
                                            &nbsp; Total Children:&nbsp;<asp:TextBox Runat="Server" id="ClientChildrenTotal" text='<%#Container.DataItem("ClientChildrenTotal")%>' columns="2"></asp:textbox>
                                        </p><p>Other Family Info:<asp:TextBox Runat="Server" id="ClientOtherFamilyInfo" text='<%#Container.DataItem("ClientOtherFamilyInfo")%>' size="20"></asp:textbox>
                                            &nbsp;&nbsp; Spousal D.O.B.&nbsp;
                                            <asp:TextBox Runat="Server" id="ClientSpousalDOB" size="20" text='<%#format(Container.DataItem("ClientSpousalDOB"), "d")%>'></asp:textbox></p><p>Phone:&nbsp;
                                            <asp:TextBox Runat="Server" id="ClientPhone" text='<%#Container.DataItem("ClientPhone")%>' size="20"></asp:textbox>&nbsp;&nbsp;
                                        </p><P>Primary Reason for Leaving:<asp:listbox Runat="server" rows="1" id="ClientReason1ID" DataTextField="ReasonforLeaving" DataValueField="ReasonID" />
                                                    </asp:listbox><p>Secondary Reason for Leaving:<asp:listbox Runat="server" rows="1" id="ClientReason2ID" DataTextField="ReasonforLeaving" DataValueField="ReasonID" />
                                         <p>First Choice Area:&nbsp;&nbsp;<asp:listbox Runat="server" rows="1" id="Client1stChoiceAreaID" DataTextField="AREAName" DataValueField="AREAID" />
                                                        </asp:listbox>&nbsp;&nbsp;
                                         First Choice Residence:&nbsp;&nbsp;<asp:listbox Runat="server" rows="1" id="Client1stChoiceResidenceType" DataTextField="ResidenceTypeCode" DataValueField="ResidenceID" />
                                                    </asp:listbox>Second Choice Area:&nbsp;<asp:listbox Runat="server" rows="1" id="Client2ndChoiceAreaID" DataTextField="AREAName" DataValueField="AREAID" />
                                                    </asp:listbox></p><P><XXXXIMPLIED_P><XXXXIMPLIED_P>Second Choice Residence:<asp:listbox Runat="server" rows="1" id="Client2ndChoiceResidenceType" DataTextField="ResidenceTypeCode" DataValueField="ResidenceID" />
                                                    </asp:listbox><P>Date Needed:&nbsp;<asp:TextBox Runat="Server" id="ClientNeedDate" text='<%#Container.DataItem("ClientNeedDate")%>' size="20"></asp:textbox>
                                                &nbsp;Immediately?&nbsp;
                                                <asp:checkbox Runat="server" id="ClientImmediateNeed" checked='<%#(Databinder.eval(Container.DataItem, "ClientImmediateNeed") = "Y")%>'></ASP:CHECKBOX>&nbsp;Notice Given?
                                    <asp:checkbox Runat="server" id="ClientNotice" checked='<%#(DataBinder.eval(Container.DataItem, "ClientNotice") = "Y")%>'></ASP:CHECKBOX><P><P></p><p>Monthly Income:&nbsp;<asp:TextBox Runat="Server" id="ClientMoIncome" size="3" text='<%#Container.DataItem("ClientMoIncome")%>'></asp:textbox>
                                        &nbsp;&nbsp;Top Price:&nbsp;&nbsp;<asp:TextBox Runat="Server" id="ClientTopAmount" size="3" text='<%#Container.DataItem("ClientTopAmount")%>'></asp:textbox>
                                        &nbsp;&nbsp;Ideal Maximum Rent:<asp:TextBox Runat="Server" id="ClientIdealRent" size="6" disabled="disabled" text='<%#Container.DataItem("ClientMoIncome")*.33%>'></asp:textbox>
                                    </p><p></p><p>Has 1st &amp; Last?&nbsp;&nbsp;<input type="checkbox" id="Client1stLast" value="1" />
                                        &nbsp;&nbsp; References?<asp:checkbox Runat="server" id="ClientHaveRefs" checked='<%#(Databinder.eval(Container.DataItem, "ClientHaveRefs")="1")%>'/>
                                    </p><p>Where From?&nbsp;
                                        <asp:listbox size="1" id="ClientOriginAreaID" Rows="1" DataTextField="AreaName" DataValueField="AreaID" runat="server" /></asp:listbox></p><p>Risk of Homelessness?<asp:TextBox Runat="Server" id="ClientHomelessRisk" text='<%#Container.DataItem("ClientHomelessRisk")%>' columns="2"></asp:textbox>
                                        &nbsp; Children Homeless:&nbsp;<asp:TextBox Runat="Server" id="ClientChildrenHomeless" text='<%#Container.DataItem("ClientChildrenHomeless")%>' columns="2"></asp:textbox>
                                        &nbsp;Number Affected:<asp:TextBox Runat="Server" id="ClientNumberAffected" text='<%#Container.DataItem("ClientNumberAffected")%>' columns="2"></asp:textbox>
                                    </p><p>Employed:<asp:TextBox Runat="Server" id="ClientEmployed" text='<%#Container.DataItem("ClientEmployed")%>' columns="2"></asp:textbox>
                                    </p><p><b>Job Sector:</b>&nbsp;Trade&nbsp;<asp:TextBox Runat="Server" id="ClientJobTrade" text='<%#Container.DataItem("ClientJobTrade")%>' columns="2"></asp:textbox>
                                        &nbsp;&nbsp;Professional<asp:TextBox Runat="Server" id="ClientJobProff" text='<%#Container.DataItem("ClientJobProff")%>' columns="2"></asp:textbox>
                                        &nbsp;&nbsp;Service:&nbsp;&nbsp;IntraWest<asp:TextBox Runat="Server" id="ClientIW" text='<%#Container.DataItem("ClientIW")%>' columns="2"></asp:textbox>
                                        BlueMtn<asp:TextBox Runat="Server" id="ClientBM" text='<%#Container.DataItem("ClientBM")%>' columns="2"></asp:textbox>
                                        Other&nbsp;<asp:TextBox Runat="Server" id="ClientJobSvc" text='<%#Container.DataItem("ClientJobSvc")%>' columns="2"></asp:textbox>
                                    </p><p><b>Manufacturing:</b>VOABYP&nbsp;<asp:TextBox Runat="Server" id="ClientVOABYP" text='<%#Container.DataItem("ClientVOABYP")%>' columns="2"></asp:textbox>
                                        &nbsp;LOF&nbsp;<asp:TextBox Runat="Server" id="ClientLOF" text='<%#Container.DataItem("ClientLOF")%>' columns="2"></asp:textbox>
                                        &nbsp;GY&nbsp;<asp:TextBox Runat="Server" id="ClientGY" text='<%#Container.DataItem("ClientGY")%>' columns="2"></asp:textbox>
                                        &nbsp;RLAlcoa<asp:TextBox Runat="Server" id="ClientRLAlcoa" text='<%#Container.DataItem("ClientRLAlcoa")%>' columns="2"></asp:textbox>
                                        &nbsp;Other<asp:TextBox Runat="Server" id="ClientJobMan" text='<%#Container.DataItem("ClientJobMan")%>' columns="2"></asp:textbox>
                                    </p><p>Pension/Benefits&nbsp;&nbsp;<asp:TextBox Runat="Server" id="ClientPensionBenefits" text='<%#Container.DataItem("ClientPensionBenefits")%>' columns="2"></asp:textbox>
                                        &nbsp;Disability&nbsp;<asp:TextBox Runat="Server" id="ClientDisability" text='<%#Container.DataItem("ClientDisability")%>' columns="2"></asp:textbox>
                                        &nbsp;EI/SickPay<asp:TextBox Runat="Server" id="ClientEISickPay" text='<%#Container.DataItem("ClientEISickPay")%>' columns="2"></asp:textbox>
                                        &nbsp;Work/Family Benefits&nbsp;<asp:TextBox Runat="Server" id="ClientWorkFamilyBenes" text='<%#Container.DataItem("ClientWorkFamilyBenes")%>' columns="2"></asp:textbox>
                                        &nbsp;<br />Child Support&nbsp;<asp:TextBox Runat="Server" id="ClientChildSupport" text='<%#Container.DataItem("ClientChildSupport")%>' columns="2"></asp:textbox>
                                        &nbsp;Child Aid&nbsp;<asp:TextBox Runat="Server" id="ClientChildAid" text='<%#Container.DataItem("ClientChildAid")%>' columns="2"></asp:textbox>
                                        &nbsp;Child Tax&nbsp;<asp:TextBox Runat="Server" id="ClientChildTax" text='<%#Container.DataItem("ClientChildTax")%>' columns="2"></asp:textbox>
                                        &nbsp;Ont Works?<asp:TextBox Runat="Server" id="ClientOntWeeks" text='<%#Container.DataItem("ClientOntWeeks")%>' columns="2"></asp:textbox>
                                    </p><p>Comments:
                                    </p><p></p><asp:textbox runat="server" id="ClientComments" textmode="multiline" text='<%#Container.DataItem("ClientComments")%>' columns="2"></asp:textbox<hr /><p>Number Housed?&nbsp;&nbsp;<asp:TextBox Runat="Server" id="ClientHousebyNo" text='<%#Container.DataItem("ClientHouseByNo")%>' columns="2"></asp:textbox>
                                        &nbsp;&nbsp; Unit Housed?&nbsp;<asp:TextBox Runat="Server" id="ClientHousebyUnit" text='<%#Container.DataItem("ClientHouseByUnit")%>' columns="2"></asp:textbox>
                                        &nbsp;Lost Contact<asp:TextBox Runat="Server" id="ClientLostContact" columns="2" text='<%#Container.DataItem("ClientLostContact")%>'></asp:textbox>
                                        &nbsp;Flex Units<asp:TextBox Runat="Server" id="ClientFlexUnits" columns="2" text='<%#Container.DataItem("ClientFlexUnits")%>'></asp:textbox>
                                        &nbsp;Stayed in Same:&nbsp;<asp:TextBox Runat="Server" id="ClientStayHome" text='<%#Container.DataItem("ClientStayHome")%>' columns="2"></asp:textbox>
                                        <br />Date Housed?<asp:TextBox Runat="Server" id="HouseDate" size="18" text='<%#format(Container.DataItem("HouseDate"), "d")%>' ></asp:textbox>
                                    </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:TemplateColumn></Columns></ASP:DataGrid>
&nbsp;&nbsp;&nbsp;&nbsp;</form>
                                </td>
                                </tr>
                                </tbody>
                                </table>
                                </body>
                                </html>
0
Comment
Question by:ClassyLinks
  • 11
  • 7
  • 5
23 Comments
 
LVL 3

Assisted Solution

by:dabitbol
dabitbol earned 250 total points
ID: 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.

0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12219442
hmmm....how would I do that??
0
 
LVL 15

Accepted Solution

by:
Thogek earned 250 total points
ID: 12219447
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 code inside that event handler's method, which would fire once per DataRow as each row is bound to the DataGrid.

DataGrid.ItemDataBound event: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemdataboundtopic.asp
0
 
LVL 15

Expert Comment

by:Thogek
ID: 12219455
Whoops.  dabitbol posted part of my comment while I was still writing it.  (Didn't mean ta parrot ya there. ;-)
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12219492
Basically, what he's saying is something that looks like this:

public Sub ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptr.ItemDataBound
   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("ClientOriginAreaID")
      Dim objCmd as New OleDbCommand("sp_listareas_display", Connect2)
                objCmd.CommandType = CommandType.StoredProcedure
              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
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12219872
thanks folks....

I'm gettng this error:   Handles clause requires a WithEvents variable.

On this line:

Line 49:     public Sub ContactGrid_OnItemDataBound(ByVal sender As Object, _
Line 50: ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptr.ItemDataBound
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12219976
Sorry you have to declare it this way:

ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ContactGrid.ItemDataBound

David
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12220013
And your Page_Load shoul be declared like this (I think, I'm a C# Programmer)


Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
...
...
...
End Sub

David
0
 
LVL 15

Expert Comment

by:Thogek
ID: 12220025
Yeah, yeah.  What dabitbol said.  ;-)
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12220166
:((

Changed Page_Load & ContactGrid_OnItemDataBound.....same error.

Any ideas??
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12220259
Gimme a minute
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:dabitbol
ID: 12220306
try adding this tag to your DataGrid because since you're using inline script it's a problem. So add this:

<asp:DataGrid ... OnItemDataBound="ContactGrid_OnItemDataBound" ... >
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12220324
And Remove the HAndles Clause:

ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12220331
:((

Same error.
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12220336
And Remove the HAndles Clause:

ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12220358
Oh Sorry, Another Error is this:


ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)


Deeply Sorry!!!
0
 
LVL 15

Expert Comment

by:Thogek
ID: 12220364
I'm no VB expert, either, but...
Does adding
    OnItemDataBound="ContactGrid_OnItemDataBound"
into your <asp:DataGrid> tag make any difference?
0
 
LVL 15

Expert Comment

by:Thogek
ID: 12220369
Doh.  Too slow again....
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12226172
Hi Folks....still there??

No luck with adding the onItemDataBound to the datagrid.....any mroe ideas??
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12227338
What's the result?
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12227632
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_display", Connect)

        myCommand.CommandType = CommandType.StoredProcedure
            'myCommand.Parameters.Add("@RegionId", RegionID)

        Connect.Open()
        Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    End Function
 
  Dim strCurrentState as Integer
 
Private Sub DG_ItemDataBound(s as object, e as DataGridItemEventArgs)
 
Dim cboStateTemp As DropDownList = CType(e.Item.FindControl("ClientOriginAreaID"), DropDownList)
Dim strTemp as String = cboStateTemp.SelectedItem.Value

       Dim myDropDown as DropDownList
       myDropDown = Ctype(e.Item.FindControl("ClientOriginAreaID"), DropDownList)
       myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.items.findbytext(strCurrentState))

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!
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 12227649
That I know you won't ba able to. But then again, it's another story!

No prob for the help!
0
 
LVL 7

Author Comment

by:ClassyLinks
ID: 12227833
thanks for your help....off to the next challenge.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now