473,408 Members | 2,405 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,408 software developers and data experts.

databinding & active row

Hi guys,
I'm new to .net & i've got a problem with regards to datasets & data
binding.

Here goes,
I've got a data grid & the active row (position) is the 3 row.
Now, i take this data set, & pass it to a seperate form, where i want to be
able to edit the details of this row.
So, in the load event of this new form, i bind the necessary columns of the
table to the required controls.

Problem -
The data displayed is that of the first row!!!!!

is this a behaviour of .Net,
where when data is bound to a control, the data will always be displayed
from the very first Row,
in other words....
is the current row in the datagrid totally independant of the dataset
(source), & has no effect on this??

--
Besty Regards,
TJ


Nov 20 '05 #1
3 2036
Cor
Hi TJ,

Before I try to get it completly what you want to do,

Have a look at currencymanager, that keeps track of the current position in
a table.

I hope this was where you was looking for?

Cor
I'm new to .net & i've got a problem with regards to datasets & data
binding.

Here goes,
I've got a data grid & the active row (position) is the 3 row.
Now, i take this data set, & pass it to a seperate form, where i want to be able to edit the details of this row.
So, in the load event of this new form, i bind the necessary columns of the table to the required controls.

Problem -
The data displayed is that of the first row!!!!!

is this a behaviour of .Net,
where when data is bound to a control, the data will always be displayed
from the very first Row,
in other words....
is the current row in the datagrid totally independant of the dataset
(source), & has no effect on this??

Nov 20 '05 #2
Hi Cor,
I've got the answer for this, could u please check thsi for me,

Consider the following scenario.

1. A datagrid with 5 records
2. The 2 row has been deleted off (but acceptchanges method has not been
called).
3. The current row position is 2 in the data grid.
4. I would like to get hold of the above datarow, but cannot use the
"CurrentRowPostion"
as a parameter for the DataGrid.DataSet.Tables(0).Rows(<Row Number>),
as if i were to do this, then i'd be accessing the deleted row & not the
row in the datagrid.

So, HOW do i get hold of the current row?????

"Cor" <no*@non.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi TJ,

Before I try to get it completly what you want to do,

Have a look at currencymanager, that keeps track of the current position in a table.

I hope this was where you was looking for?

Cor
I'm new to .net & i've got a problem with regards to datasets & data
binding.

Here goes,
I've got a data grid & the active row (position) is the 3 row.
Now, i take this data set, & pass it to a seperate form, where i want to

be
able to edit the details of this row.
So, in the load event of this new form, i bind the necessary columns of

the
table to the required controls.

Problem -
The data displayed is that of the first row!!!!!

is this a behaviour of .Net,
where when data is bound to a control, the data will always be displayed
from the very first Row,
in other words....
is the current row in the datagrid totally independant of the dataset
(source), & has no effect on this??


Nov 20 '05 #3
Cor
Hi TJ,

Try this sample I did make.
Open a new windows form project and paste this code in.
\\\You need to drag 2 datagrids and 2 buttons on the form.
Dim ds As New DataSet
Dim dv As New DataView
Dim dt As New DataTable
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button1.Text = "Delete"
Me.Button2.Text = "New"
For i As Integer = 0 To 3
Dim dc As New DataColumn(Chr(i + 65))
dt.Columns.Add(dc)
Next
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(i + 65)
Next
Next
ds.Tables.Add(dt)
dv = New DataView(ds.Tables(0))
dv.Sort = "b Desc"
DataGrid1.DataSource = dv
DataGrid2.DataSource = ds.Tables(0)
Me.DataGrid2.ReadOnly = True
Me.DataGrid2.CaptionVisible = False
Me.DataGrid2.ColumnHeadersVisible = False
Me.DataGrid2.DataMember = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
dv.Delete(DirectCast(BindingContext(dv), CurrencyManager).Position)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Static a As Integer = 12
Dim dr As DataRow = dt.NewRow
dt.Rows.Add(dr)
For y As Integer = 0 To dt.Columns.Count - 1
dr(y) = Chr(a + 65)
Next
a += 1
End Sub
Nov 20 '05 #4

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

Similar topics

0
by: Jason S | last post by:
I haven't been able to get an answer to this in the asp.net group, hoping someone here can enlighten me. As pertains to databinding a control in a repeating fashion(datagrid, repeater, etc.)...
0
by: Richard | last post by:
Hi, I'm having issues with DataBinding. I have a Form with two data bound comboboxes on it. When you select something in one combobox I may {or may not} want to change the selected item in the...
6
by: eye5600 | last post by:
Is there a cure for the problems using databinding with a DateTimePicker? I find that a) sometimes it works, sometimes it doesn't, and b) it fails silently causing all databinding on the DataSet...
1
by: Vik | last post by:
Concatenation operator & used in the databinding expressions for the datagrid template columns appears as '&amp;' in HTML. It causes an error when opening the pages. I have to replace '&amp;' by '&' each...
2
by: Bruno Rodrigues | last post by:
The controls in my form are bounded to a datasource, including textboxes, comboboxes, etc... Something lame happens: In runtime, the last focused control before clicking on my save button, doesn't...
2
by: Kalpesh | last post by:
Hello, I am facing a design problem here & need your expert design advice on this. Scenario: I have a class called Vendor - which has several simple attributes like Name, Address etc Now,...
1
by: esakal | last post by:
Hello, I have a very strange problem which involve databinding in winform c#.net 2 . I have a user control which holds textbox inside. the user control has property which reflect the...
2
by: mikeachamberlain | last post by:
Hi. I have an <asp:Imagecontrol in which I am databinding the ImageURL attribute. The URL is another ASPX page that provides the binary source of the image, The problem is that ASP.NET is...
0
by: Chris | last post by:
Hello, I have a problem with re-loading datasets. As a simple example, if I have an SQL table of addresses comprising active and inactive addresss, I wish to load either sub-set by clicking on...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.