rotaxmax12
Technical User
I have a data entry form that you select a primary and secondary contact. The first drop down list populates just fine, but the second drop down list is loading with all 0 (zeros) in the DataValue field. I see this when I View Source on the page.
This is happening when the page is building. No data entry has taken place yet.
VB Code:
'This list populates correctly.
SQLText = "SELECT idsContactID, LTRIM(RTRIM(IsNull(strFirstName,'') + ' ' + IsNull(strLastName,''))) AS ContactName FROM dbo.tblContacts WHERE idnCompanyID=" & Session("CompanyID")
cmd = New SqlCommand(SQLText, BrandedConn)
Dim pcon As SqlDataReader
pcon = cmd.ExecuteReader()
Do
With DesigAppContact
.DataSource = pcon
.DataTextField = "ContactName"
.DataValueField = "idsContactID"
.DataBind()
.Items.Insert(0, New ListItem("Select Primary Contact", 0))
End With
Loop While pcon.Read()
pcon.Close()
'This is populating the drop down with the DataValue = 0
SQLText = "SELECT idsContactID, LTRIM(RTRIM(IsNull(strFirstName,'') + ' ' + IsNull(strLastName,''))) AS ContactName FROM dbo.tblContacts WHERE idnCompanyID=" & Session("CompanyID")
cmd = New SqlCommand(SQLText, BrandedConn)
Dim dccCon As SqlDataReader
dccCon = cmd.ExecuteReader()
Do
With DesigClaimContact
.DataSource = dccCon
.DataTextField = "ContactName"
.DataValueField = "idsContactID"
.DataBind()
.Items.Insert(0, New ListItem("Select Designated Claim Contact", 0))
End With
Loop While dccCon.Read()
dccCon.Close()
HTML/ASP Page code:
<tr>
<td class="styleLeftSide">Designated Application Contact:</td>
<td class="styleRightSide"><aspropDownList ID="DesigAppContact" runat="server" DataValueField="idsContactID" DataTextField="ContactName"></aspropDownList></td>
</tr>
<tr>
<td class="styleLeftSide">Designated Claims Contact:</td>
<td class="styleRightSide"><aspropDownList ID="DesigClaimContact" runat="server" DataValueField="idsContactID" DataTextField="ContactName"></aspropDownList></td>
</tr>
Many thanks for any assistance.
JJ
This is happening when the page is building. No data entry has taken place yet.
VB Code:
'This list populates correctly.
SQLText = "SELECT idsContactID, LTRIM(RTRIM(IsNull(strFirstName,'') + ' ' + IsNull(strLastName,''))) AS ContactName FROM dbo.tblContacts WHERE idnCompanyID=" & Session("CompanyID")
cmd = New SqlCommand(SQLText, BrandedConn)
Dim pcon As SqlDataReader
pcon = cmd.ExecuteReader()
Do
With DesigAppContact
.DataSource = pcon
.DataTextField = "ContactName"
.DataValueField = "idsContactID"
.DataBind()
.Items.Insert(0, New ListItem("Select Primary Contact", 0))
End With
Loop While pcon.Read()
pcon.Close()
'This is populating the drop down with the DataValue = 0
SQLText = "SELECT idsContactID, LTRIM(RTRIM(IsNull(strFirstName,'') + ' ' + IsNull(strLastName,''))) AS ContactName FROM dbo.tblContacts WHERE idnCompanyID=" & Session("CompanyID")
cmd = New SqlCommand(SQLText, BrandedConn)
Dim dccCon As SqlDataReader
dccCon = cmd.ExecuteReader()
Do
With DesigClaimContact
.DataSource = dccCon
.DataTextField = "ContactName"
.DataValueField = "idsContactID"
.DataBind()
.Items.Insert(0, New ListItem("Select Designated Claim Contact", 0))
End With
Loop While dccCon.Read()
dccCon.Close()
HTML/ASP Page code:
<tr>
<td class="styleLeftSide">Designated Application Contact:</td>
<td class="styleRightSide"><aspropDownList ID="DesigAppContact" runat="server" DataValueField="idsContactID" DataTextField="ContactName"></aspropDownList></td>
</tr>
<tr>
<td class="styleLeftSide">Designated Claims Contact:</td>
<td class="styleRightSide"><aspropDownList ID="DesigClaimContact" runat="server" DataValueField="idsContactID" DataTextField="ContactName"></aspropDownList></td>
</tr>
Many thanks for any assistance.
JJ