homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Loop asp.net assistance
hal12b

5+ Year Member



 
Msg#: 4360865 posted 3:25 pm on Sep 10, 2011 (gmt 0)

I have a search box and am asking users to enter a last name. What I have works, but it only returns one answer. It is very possible that there could be results where users have the same last name. Instead of displaying

FNAME, LNAME
CITY, STATE, ZIP

I want

FNAME, LNAME
CITY, STATE, ZIP

FNAME, LNAME
CITY, STATE, ZIP

FNAME, LNAME
CITY, STATE, ZIP

FNAME, LNAME
CITY, STATE, ZIP


Any suggestions?
Thanks

 

hal12b

5+ Year Member



 
Msg#: 4360865 posted 3:26 pm on Sep 10, 2011 (gmt 0)

If this helps, this is the code I have that displays one result.


Dim strid = txtlname.Text
'Response.write(strid)


Dim cmsData As New DataTable
Dim cmsCt As New SqlConnection(ConnectionString)
Dim cmsAdapt As New SqlDataAdapter

'Try
Dim cmsQuery As String = "SELECT * FROM tblinfo WHERE VISIBLE = '1' AND LNAME = @LNAME "




cmsAdapt.SelectCommand = New SqlCommand(cmsQuery, cmsCt)
cmsAdapt.SelectCommand.Parameters.Add(New SqlParameter("@LNAME", strid))

cmsAdapt.Fill(cmsData)
cmsCt.Close()
' Catch ex As Exception
' lblErrors.Text = "Could not connect to CMSWebData"
'Exit Sub
' End Try

If cmsData.Rows.Count > 0 Then
Dim dr As DataRow = cmsData.Rows(0)
strfname = Utils.CheckForNull_Text(dr.Item("FNAME"), "")
strlname = Utils.CheckForNull_Text(dr.Item("LNAME"), "")
strcity = Utils.CheckForNull_Text(dr.Item("CITY"), "")
strstate = Utils.CheckForNull_Text(dr.Item("STATE"), "")
strcomments = Utils.CheckForNull_Text(dr.Item("COMMENTS"), "")
strzip = Utils.CheckForNull_Text(dr.Item("ZIP"), "")
strwherefound = Utils.CheckForNull_Text(dr.Item("WHERE_FOUND_TOWN"), "")
strwherefoundstate = Utils.CheckForNull_Text(dr.Item("WHERE_FOUND_STATE"), "")
strwherefoundloc = Utils.CheckForNull_Text(dr.Item("WHERE_FOUND_LOCATION"), "")
strwherefounddate = Utils.CheckForNull_Text(dr.Item("WHERE_FOUND_DATE"), "")


'labels to display information
lblfname.Text = strfname
lbllname.Text = strlname
lblcity.Text = strcity
lblstate.Text = strstate
lblcomments.Text = strcomments
lblzip.Text = strzip
lblwherefound.Text = strwherefound

lblwherefoundstate.Text = strwherefoundstate
lblwherefoundlocation.Text = strwherefoundloc
lblwherefounddate.Text = strwherefounddate



MultiView1.SetActiveView(View2)

hal12b

5+ Year Member



 
Msg#: 4360865 posted 7:53 pm on Sep 12, 2011 (gmt 0)

Bueller? Bueller?

johnblack



 
Msg#: 4360865 posted 8:06 pm on Sep 12, 2011 (gmt 0)

Hi,

It's not so much an issue with the code as an issue with the page layout.

You've declared only one set of labels, lblfname etc so the page can physically display only one set of results.

A possible solution would be to use a data grid on the page and bind the SQL adapter to it.

bmcgee

10+ Year Member



 
Msg#: 4360865 posted 11:46 pm on Sep 13, 2011 (gmt 0)

Better yet would be a Repeater, much more lightweight than a data grid.

hal12b

5+ Year Member



 
Msg#: 4360865 posted 12:16 pm on Sep 14, 2011 (gmt 0)

OK. Thank you. I will give it a shot tonight. I reused code from another project where there was only result.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved