Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2005, 01:19 PM
Authorized User
 
Join Date: Jul 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with DropDownList on String Value Field

Hi,

I'm trying to code a dropdownlist with a string field as the datavaluefield. I have mainly done
integer field lookups before, so I'm having problems with syntax. Here's my code for page_load,
indexChanged and BindGrid.
-------------------------------------
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
Dim CurrentUser As SiteIdentity = CType(Context.User.Identity, SiteIdentity)
Dim CompanyName As String = CurrentUser.CompanyName
UserIdentifier.Text = UserIdentifier.Text & "<b>" & CurrentUser.CompanyName & "</b>"
Dim PropName As String = Request.Params("PropName")
DataGrid1.Attributes("PropName") = PropName
Dim PropNameDataView As DataView = _
Business.VendorEquipment.GetPropName(CompanyName). Tables(0).DefaultView
PropDropDown.DataSource = PropNameDataView
PropDropDown.DataBind()
If Not (PropName Is Nothing) Then
PropDropDown.SelectedIndex = PropDropDown.SelectedItem.Value
End If

BindGrid()

End If
End Sub

Protected Sub PropDropDown_IndexChanged( _
ByVal sender As Object, _
ByVal e As EventArgs)
Response.Redirect(("PropertyEquipment.aspx?PropNam e=" & _
PropDropDown.SelectedItem.Value))
End Sub



Private Sub BindGrid()
Dim PropName As String
If Not (DataGrid1.Attributes("PropName") Is Nothing) Then
PropName = DataGrid1.Attributes("PropName")
Else
PropName = PropDropDown.SelectedItem.Value
End If
Dim GVEDataSet As DataSet = New _
Business.VendorEquipment(PropName).GetVendorEquipm ent("PropName")
DataGrid1.DataSource = GVEDataSet
DataGrid1.DataBind()

End Sub
-------------------------------
I'm getting an error on attempting to load the page that states "Cast from String 'PropName'
to type'integer' is not valid.

Can anyone tell me what's wrong in this code.
Thx
Reid C.



Reid C.
__________________
Reid C.
 
Old May 31st, 2005, 08:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Seems like one of the collections requires an integer value and not the string "PropName"; maybe Request.Params? I am not sure, check the MSDN to see if the collections require the appropriate types.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
2 field Values within DropDownList.DataValueField rit01 ASP.NET 2.0 Basics 4 May 11th, 2016 03:22 AM
Missing borders on a empty string field ProfGerdes Crystal Reports 1 March 15th, 2012 03:14 PM
string compare in table field alxtech SQL Server 2000 1 April 27th, 2007 12:25 AM
Assigning string to a number field p_gauri7 Crystal Reports 3 December 10th, 2004 10:43 AM
Query Problem with a field string Brian263 Access 2 November 19th, 2004 05:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.