473,385 Members | 1,888 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,385 software developers and data experts.

Don't Understand

I am working on a walkthrough that allows editing contents of a datagrid
that is displaying some fields from a table in the Northwind DB. The update
code thay have you enter is shown below. As noted in the code, I am confused
by the statement that DIM's the "r" variable using "dsCategories", not
"dsCategories1". The code works fine but I am trying to understand what is
going on here.

TIA

Wayne

=================== code ======================
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand

Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()

Dim categoryName, categoryDescription As String

Dim tb As TextBox

tb = CType(e.Item.Cells(2).Controls(0), TextBox)

categoryName = tb.Text

tb = CType(e.Item.Cells(3).Controls(0), TextBox)

categoryDescription = tb.Text

Dim r As dsCategories.CategoriesRow <= What is
"dsCategories"? My solution shows "dsCategories1"?

r = DsCategories1.Categories.FindByCategoryID(key)

r.CategoryName = categoryName

r.Description = categoryDescription

SqlDataAdapter1.Update(DsCategories1)

DataGrid1.DataBind()

'Switch current row out of edit mode

DataGrid1.EditItemIndex = -1

DataGrid1.DataBind()

End Sub

================================================== ===================
Nov 18 '05 #1
2 1061
I'm making an assumtion here, that you're working with a strongly types
dataset. If you aren't then ignore this posting...

IF you have atypes dataset, then there are pre-defined type for the
following....
DsCategories (Which derives from DataSet)
DsCategories.CategoriesRow (Which Derived From DataRow, this is a type, the
"dot" does not define it as a property, but as a type that is defined within
the DsCategories class/namespace)
DsCategories1 is an instance of a Strongly Types Dataset, which is of the
type DsCategories

so r is being declared as a specific type of DataRow,
Dim r As dsCategories.CategoriesRow
then its being set to be equal to the row, within your instance of the
DsCategories dataset, categoryID is equal to some value
r = DsCategories1.Categories.FindByCategoryID(key)
if you changed your code so that the dataset variable was something more
generic like ds, instead of DsCategories1, then it might make a little more
sense.
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I am working on a walkthrough that allows editing contents of a datagrid
that is displaying some fields from a table in the Northwind DB. The update code thay have you enter is shown below. As noted in the code, I am confused by the statement that DIM's the "r" variable using "dsCategories", not
"dsCategories1". The code works fine but I am trying to understand what is
going on here.

TIA

Wayne

=================== code ======================
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand

Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()

Dim categoryName, categoryDescription As String

Dim tb As TextBox

tb = CType(e.Item.Cells(2).Controls(0), TextBox)

categoryName = tb.Text

tb = CType(e.Item.Cells(3).Controls(0), TextBox)

categoryDescription = tb.Text

Dim r As dsCategories.CategoriesRow <= What is
"dsCategories"? My solution shows "dsCategories1"?

r = DsCategories1.Categories.FindByCategoryID(key)

r.CategoryName = categoryName

r.Description = categoryDescription

SqlDataAdapter1.Update(DsCategories1)

DataGrid1.DataBind()

'Switch current row out of edit mode

DataGrid1.EditItemIndex = -1

DataGrid1.DataBind()

End Sub

================================================== ===================

Nov 18 '05 #2
Thanks for the reply David. Let me try to digest your information.

Wayne

"David Jessee" <dj*****@houston.rr.com> wrote in message
news:eP****************@tk2msftngp13.phx.gbl...
I'm making an assumtion here, that you're working with a strongly types
dataset. If you aren't then ignore this posting...

IF you have atypes dataset, then there are pre-defined type for the
following....
DsCategories (Which derives from DataSet)
DsCategories.CategoriesRow (Which Derived From DataRow, this is a type, the "dot" does not define it as a property, but as a type that is defined within the DsCategories class/namespace)
DsCategories1 is an instance of a Strongly Types Dataset, which is of the
type DsCategories

so r is being declared as a specific type of DataRow,
Dim r As dsCategories.CategoriesRow
then its being set to be equal to the row, within your instance of the
DsCategories dataset, categoryID is equal to some value
r = DsCategories1.Categories.FindByCategoryID(key)
if you changed your code so that the dataset variable was something more
generic like ds, instead of DsCategories1, then it might make a little more sense.
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I am working on a walkthrough that allows editing contents of a datagrid
that is displaying some fields from a table in the Northwind DB. The

update
code thay have you enter is shown below. As noted in the code, I am

confused
by the statement that DIM's the "r" variable using "dsCategories", not
"dsCategories1". The code works fine but I am trying to understand what is going on here.

TIA

Wayne

=================== code ======================
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand

Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()

Dim categoryName, categoryDescription As String

Dim tb As TextBox

tb = CType(e.Item.Cells(2).Controls(0), TextBox)

categoryName = tb.Text

tb = CType(e.Item.Cells(3).Controls(0), TextBox)

categoryDescription = tb.Text

Dim r As dsCategories.CategoriesRow <= What is
"dsCategories"? My solution shows "dsCategories1"?

r = DsCategories1.Categories.FindByCategoryID(key)

r.CategoryName = categoryName

r.Description = categoryDescription

SqlDataAdapter1.Update(DsCategories1)

DataGrid1.DataBind()

'Switch current row out of edit mode

DataGrid1.EditItemIndex = -1

DataGrid1.DataBind()

End Sub

================================================== ===================


Nov 18 '05 #3

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
4
by: Bart | last post by:
Hi all I don't understand globals between multiple modules in a python program. I really don't. I've narrowed it down to the following two very simple programs a.py and b.py. When I run a.py I...
7
by: Robert Nicholson | last post by:
So I've got one page where I have an image inside a DIV with text-align: center and the image is correctly centered in that block. Making me think that text-align will center the contents of a...
16
by: Jace Benson | last post by:
Ok I have read alot of things on zend.com, php.net and other sites went to the wikibooks to try to understand how to use a class. I have this project I want to do that I am sure would work great...
17
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post by:
Hello, I have build a website with approximately 30 html-pages. When I search this website in Google, I see the index.html or home.html on this website, but also other html-pages on this...
31
by: Jo | last post by:
class A { public: char text_a; A() { *text_a=0; } ~A() {} }; //-----------------------------------------------------------------------------
21
by: jehugaleahsa | last post by:
Hello: I had an hour-long discussion with my boss today. Last night, right before I dozed off, I realized some of his code resulted in duplicate processing. I tried to explain it to him and he...
3
by: Ben Thomas | last post by:
Hello, I have the following code which I don't understand why it works : #include <iostream> using namespace std; void DontWork (unsigned int& i) { cout << i << endl; }
0
by: Stef Mientki | last post by:
Terry Reedy wrote: sorry, don't know how this happened, as I always copy/paste ? AFAIK locals() == sys._getframe(0).f_locals AFAIK, again one level up weird, I use it in 2.5 and if I remember...
5
by: Thierry | last post by:
Hello fellow pythonists, I'm a relatively new python developer, and I try to adjust my understanding about "how things works" to python, but I have hit a block, that I cannot understand. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
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
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
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...

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.