473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with Textbox controls on Web form

Denis,

I recommend you to bind the textbox controls to columns
of your table inside your dataset, then get the
bindingmanagerbase for the table, then use the position
property of the bindingmanagerbase to navigate previous
and next.

Rogelio Moreno

-----Original Message-----
I need a little help to be able to use a Next and Previous button toget the next record or the previous record to Textboxes instead of adatagird. I am using a stored procedure to get the data I want fromthe SQL Server 2000 database. And I can get it into the textboxes.Sometimes there will be multiple records in the dataset but I can onlyget the first record in the textboxes, thus the need to have the Nextand Previous record button. Any help will be appreacted. I am alsoputting some of my code here to give you a idea of what I am doing. Itis all hardcoded.

Thanks

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnSearch.Click
If txtLastName.Text <> "" Then
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter

'Create a connection to the SQL Server.
MyConnection = New SqlConnection("server= (local);database=dsgtest;Trusted_Connection=yes")
'Create a DataAdapter, and then provide the name of the storedprocedure.
MyDataAdapter = New SqlDataAdapter("LastName", MyConnection)
'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create and add a parameter to Parameters collection for the storedprocedure.
MyDataAdapter.SelectCommand.Parameters.Add(New
SqlParameter("@em_lName", _
SqlDbType.VarChar, 40))

'Assign the search value to the parameter.
MyDataAdapter.SelectCommand.Parameters ("@em_lname").Value =Trim(txtLastName.Text)

'Create and add an output parameter to Parameters collection.MyDataAdapter.SelectCommand.Parameters.Add(New
SqlParameter("@RowCount", _
SqlDbType.Int, 4))

'Set the direction for the parameter. This parameter returns the Rowsreturned.
MyDataAdapter.SelectCommand.Parameters ("@RowCount").Direction =ParameterDirection.Output

DS = New DataSet() 'Create a new DataSet to hold the records.MyDataAdapter.Fill(DS, "dsLastName") 'Fill the DataSet with the rowsreturned.

' Get the number of rows returned, and then assign it to the Labelcontrol.
'lblRowCount.Text = DS.Tables(0).Rows.Count().ToString() & " RowsFound!"

lblRowCount.Text = MyDataAdapter.SelectCommand.Parameters (1).Value & "Records Found for Last Name of " & txtLastName.Text & " search!"
'Set the data source for the DataGrid as the DataSet that holds therows.
'dgGrid.DataSource = DS.Tables("dsLastName").DefaultView

Dim lname = DataBinder.Eval(DS,
"Tables(0).defaultview.(0).lastname").ToString( )
Dim fname = DataBinder.Eval(DS,
"Tables(0).defaultview.(0).firstname").ToString ()
Dim pnumber = DataBinder.Eval(DS,
"Tables(0).defaultview.(0).phone").ToString()

TextBox1.Text = lname
TextBox2.Text = fname
TextBox3.Text = pnumber

Label1.Text = fname + " " + lname + " Phone Number " + pnumber
MyDataAdapter.Dispose() 'Dispose of the DataAdapter.
MyConnection.Close() 'Close the connection.
End If

End Sub

Private Sub btnPrev_Command(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.CommandEventArgs) Handles btnPrev.Command
End Sub

Private Sub btnNext_Command(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.CommandEventArgs) Handles btnNext.Command
End Sub

End Class
.

Nov 20 '05 #1
0 1695

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mike | last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am trying to implement a singleton class. Form 1 should create a user object and populate some properties in user. Form2...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
5
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
3
by: Keith Mills | last post by:
Hello, please find attached a basic outline of what I am attempting to accomplish... basically I want to create a number of THREADS (which I can do fine), but I then need a method for them to be...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
6
by: kberry | last post by:
I am clearing Textboxes on a form... this is loop I have came up with but was wondering if it can be shorter or not as long... Can anyone help? Dim controlOnForm As Control 'Places a control...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.