473,473 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataBind - user type to change the Position

144 New Member
hi,

i'm going to develop a program using VB .NET.

i've bound some textboxes to the same DataSource (DataSet1.Tables(0).
and i enable the user to type the primaryKey of the data in the Table, so if the user has typed an existing PK in the table, the position of the CurrencyManager will be changed. in the 'KeyUp' event of the ID textBox, i implement this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtID_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtID.KeyUp
  2.         If txtID.Text = "" Then Exit Sub
  3.  
  4.         Dim index As Integer
  5.         For index = 0 To DataSet1.Tables(0).Rows.Count - 1
  6.             If CStr(DataSet1.Tables(0).Rows(index).Item("employeeID")) = txtID.Text Then
  7.                 CType(BindingContext(DataSet1.Tables(0)), CurrencyManager).Position = index
  8.             End If
  9.         Next
  10.  
  11.         Debug.WriteLine(CStr(DataSet1.Tables(0).Rows.Count - 1) + " " + txtID.Text)
  12.     End Sub
  13.  
then i try typing some existing PK in the table and a problem occurs, the data won't change if:
1. i type "2", "3", "4" (any existing PK) then i go back to those i "have visited" like "1" or "2" or "3" the data won't change, but i does change if i type "6" or "7" or "8" (any row that i "haven't visited")

2. i type "9", which is the last data in the Table. than i type any other PK like "7", "8", "1", "5". the data represented won't change.


is there any probelm with my code ?

thanks in advance.
Oct 11 '08 #1
1 1202
thesti
144 New Member
hi,

it seems i know what cause the problem.

seems that because i also bound the txtID to the DataTable, so that when i type something in the txtID textbox, the underlying data is also changed.

when the program runs, i'm in the firstrow. of which emplooyeID is "1", then i type "2", the employeeID value for the firstRow is changed to "2". that's why i couldn't go back to "1".

is there any workaround for this? because i have a prev, next button to let the user iterates the data. if the txtID is not bound, then it's text won't be updated as the user presses the button.


thanks
Oct 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jimmy | last post by:
Hi all I want to databind a dropdownlist in a datagrid: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here
11
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set...
5
by: Jurgen Appelo | last post by:
I'm at a loss here... My FormView control automatically performs a databind at each postback on the server. But in some cases I don't want this to happen. Like when the business layer decides that...
1
by: Matt Lowrance | last post by:
I have created an object that has a number of properties, that I am now trying to simply databind to a form. I am using the data designer to do it and just dragging and dropping the items onto the...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.