Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1125
  • Last Modified:

BC30451: item not declared?

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
ClassyLinks
Asked:
ClassyLinks
  • 11
  • 7
  • 5
2 Solutions
 
dabitbolCommented:
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
 
ClassyLinksAuthor Commented:
hmmm....how would I do that??
0
 
ThogekCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ThogekCommented:
Whoops.  dabitbol posted part of my comment while I was still writing it.  (Didn't mean ta parrot ya there. ;-)
0
 
dabitbolCommented:
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
 
ClassyLinksAuthor Commented:
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
 
dabitbolCommented:
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
 
dabitbolCommented:
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
 
ThogekCommented:
Yeah, yeah.  What dabitbol said.  ;-)
0
 
ClassyLinksAuthor Commented:
:((

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

Any ideas??
0
 
dabitbolCommented:
Gimme a minute
0
 
dabitbolCommented:
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
 
dabitbolCommented:
And Remove the HAndles Clause:

ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
0
 
ClassyLinksAuthor Commented:
:((

Same error.
0
 
dabitbolCommented:
And Remove the HAndles Clause:

ContactGrid_OnItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
0
 
dabitbolCommented:
Oh Sorry, Another Error is this:


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


Deeply Sorry!!!
0
 
ThogekCommented:
I'm no VB expert, either, but...
Does adding
    OnItemDataBound="ContactGrid_OnItemDataBound"
into your <asp:DataGrid> tag make any difference?
0
 
ThogekCommented:
Doh.  Too slow again....
0
 
ClassyLinksAuthor Commented:
Hi Folks....still there??

No luck with adding the onItemDataBound to the datagrid.....any mroe ideas??
0
 
dabitbolCommented:
What's the result?
0
 
ClassyLinksAuthor Commented:
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
 
dabitbolCommented:
That I know you won't ba able to. But then again, it's another story!

No prob for the help!
0
 
ClassyLinksAuthor Commented:
thanks for your help....off to the next challenge.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 11
  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now