473,614 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSDN Examples flawed

Hi all,

I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:

=============== =========
On Page_Load
if !IsPostBack: BindGrid()

On_Edit
Set datagrid's EditItem to clicked item
BindGrid

void BindGrid()
Fill DataSet through dataadapter
DataGrid.DataBi nd()
=============== =========

Imagine a simple table "Names" with two columns: NameID and Name

Your SQL Select Statement reads "SELECT NameID, Name FROM Names ORDER BY
Name" and you have two records in it:
ID=1, Name = "aaaa"
ID=2, Name = "cccc"

So, the first time you call the page, you get following grid:
1 "aaaa" edit-button
2 "cccc" edit-button

during the time in which you are viewing this html page on your IE someone
inserts another record in the table: "ID=3, Name='bbbb'".
Then you click the edit button of the second row into your grid (2
"cccc") intending to edit the name "cccc". When you klick the edit button,
however, you get following grid:
1 "aaaa" edit-button
3 [bbbb] - updatable!!! Update-button, cancel-button
2 "cccc" edit-button

I am sure, you ghet what the reason is. What is the best solution to guard
against this problem?

Thank you for taking your time and understanding what I mean. I thought of a
logical solution which however does not work. In case a discussion occur, I
will write about it.

All best

Stamen
Nov 17 '05 #1
10 1902
Stamen,

Typically when doing an operation like this you wouldn't rebind the grid
before the edit operation.

So, in the page load sub use:

If Not IsPostBack Then
'---Bind your grid here
End If

(Make certain that viewstate is turned on for the grid. This way you don't
have to rebind the grid.)

Then rebind the grid after you edit the data.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:

=============== =========
On Page_Load
if !IsPostBack: BindGrid()

On_Edit
Set datagrid's EditItem to clicked item
BindGrid

void BindGrid()
Fill DataSet through dataadapter
DataGrid.DataBi nd()
=============== =========

Imagine a simple table "Names" with two columns: NameID and Name

Your SQL Select Statement reads "SELECT NameID, Name FROM Names ORDER BY
Name" and you have two records in it:
ID=1, Name = "aaaa"
ID=2, Name = "cccc"

So, the first time you call the page, you get following grid:
1 "aaaa" edit-button
2 "cccc" edit-button

during the time in which you are viewing this html page on your IE someone
inserts another record in the table: "ID=3, Name='bbbb'".
Then you click the edit button of the second row into your grid (2
"cccc") intending to edit the name "cccc". When you klick the edit button,
however, you get following grid:
1 "aaaa" edit-button
3 [bbbb] - updatable!!! Update-button, cancel-button
2 "cccc" edit-button

I am sure, you ghet what the reason is. What is the best solution to guard
against this problem?

Thank you for taking your time and understanding what I mean. I thought of a logical solution which however does not work. In case a discussion occur, I will write about it.

All best

Stamen

Nov 17 '05 #2
Hallo Justin,

thanks for replying. What you propose however is exactly what I am doing:
The code below is not immune against database changes:

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack)
{
this.da.Fill(ds 1, "Countrys") ;
this.DataGrid1. DataBind();
}
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
this.da.Fill(ds 1, "Names");
DataGrid1.EditI temIndex = e.Item.ItemInde x;
DataGrid1.DataB ind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
Stamen,

Typically when doing an operation like this you wouldn't rebind the grid
before the edit operation.

So, in the page load sub use:

If Not IsPostBack Then
'---Bind your grid here
End If

(Make certain that viewstate is turned on for the grid. This way you don't
have to rebind the grid.)

Then rebind the grid after you edit the data.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:

=============== =========
On Page_Load
if !IsPostBack: BindGrid()

On_Edit
Set datagrid's EditItem to clicked item
BindGrid

void BindGrid()
Fill DataSet through dataadapter
DataGrid.DataBi nd()
=============== =========

Imagine a simple table "Names" with two columns: NameID and Name

Your SQL Select Statement reads "SELECT NameID, Name FROM Names ORDER BY
Name" and you have two records in it:
ID=1, Name = "aaaa"
ID=2, Name = "cccc"

So, the first time you call the page, you get following grid:
1 "aaaa" edit-button
2 "cccc" edit-button

during the time in which you are viewing this html page on your IE someone inserts another record in the table: "ID=3, Name='bbbb'".
Then you click the edit button of the second row into your grid (2
"cccc") intending to edit the name "cccc". When you klick the edit button, however, you get following grid:
1 "aaaa" edit-button
3 [bbbb] - updatable!!! Update-button, cancel-button
2 "cccc" edit-button

I am sure, you ghet what the reason is. What is the best solution to guard against this problem?

Thank you for taking your time and understanding what I mean. I thought
of a
logical solution which however does not work. In case a discussion
occur, I
will write about it.

All best

Stamen


Nov 17 '05 #3
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:


Could you please post a reference to an MSDN article which says you should
reload the data from the database before the edit?
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
Nov 17 '05 #4
Stamen,

As long as your entries have a primary key I don't see how they could be
compromised. Of course any well designed database uses a primary key to make
certain that a row is unique.

Are the Id's that you are referring to not primary keys?

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hallo Justin,

thanks for replying. What you propose however is exactly what I am doing:
The code below is not immune against database changes:

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack)
{
this.da.Fill(ds 1, "Countrys") ;
this.DataGrid1. DataBind();
}
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
this.da.Fill(ds 1, "Names");
DataGrid1.EditI temIndex = e.Item.ItemInde x;
DataGrid1.DataB ind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
Stamen,

Typically when doing an operation like this you wouldn't rebind the grid
before the edit operation.

So, in the page load sub use:

If Not IsPostBack Then
'---Bind your grid here
End If

(Make certain that viewstate is turned on for the grid. This way you don't
have to rebind the grid.)

Then rebind the grid after you edit the data.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet (with MSDN, too!) showing datagrid's databinding. Here is, how they look like:

=============== =========
On Page_Load
if !IsPostBack: BindGrid()

On_Edit
Set datagrid's EditItem to clicked item
BindGrid

void BindGrid()
Fill DataSet through dataadapter
DataGrid.DataBi nd()
=============== =========

Imagine a simple table "Names" with two columns: NameID and Name

Your SQL Select Statement reads "SELECT NameID, Name FROM Names ORDER BY Name" and you have two records in it:
ID=1, Name = "aaaa"
ID=2, Name = "cccc"

So, the first time you call the page, you get following grid:
1 "aaaa" edit-button
2 "cccc" edit-button

during the time in which you are viewing this html page on your IE
someone inserts another record in the table: "ID=3, Name='bbbb'".
Then you click the edit button of the second row into your grid (2
"cccc") intending to edit the name "cccc". When you klick the edit button, however, you get following grid:
1 "aaaa" edit-button
3 [bbbb] - updatable!!! Update-button, cancel-button
2 "cccc" edit-button

I am sure, you ghet what the reason is. What is the best solution to guard against this problem?

Thank you for taking your time and understanding what I mean. I

thought of
a
logical solution which however does not work. In case a discussion

occur,
I
will write about it.

All best

Stamen



Nov 17 '05 #5
John,

an example of Datagrid using can be found at:
http://msdn.microsoft.com/library/en...asp?frame=true

Forget the Update event, concentrate on the Edit -it illustrates the point
nicely.

What they do is the following:
They get the row number (for example 2) which should be edited from the
datagrid's viewstate and set this row in the datagrid to be edited (row 2).
then they re-read the data and rebind the grid. If, however, the newly
reloaded data contains another row on that place (2) we get the
inconsistency.

I tried Auto generate columns=true, primary keys and so on... nothing
wirks..

Thanks
Stamen

"John Saunders" <jo***********@ surfcontrol.com > schrieb im Newsbeitrag
news:u6******** *****@TK2MSFTNG P09.phx.gbl...
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:


Could you please post a reference to an MSDN article which says you should
reload the data from the database before the edit?
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

Nov 17 '05 #6
Hi Justin,

the table has two Columns: CountryID and Country - the sorting is done on
Country not on CountryID, which of course is a primary key. The prblem of
this approach is that it expects when refilling the datagrid that all
records will come in the same order, what is quite an optimistic expectation
in the general case.

I tried your proposition of not refilling the dataadapter - it does not work
at all, as now data gets shown on the repost.

I had tried another approach:

On_Edit_Event
set editIndex=click edIndex
Exit

hoping that the grid gets reloaded from the ViewState. Unfortunately this
does not work for some reason: The first time i click [Edit], nothing
happens. The second time I click - the record enters edit-state wehich I
have clicked the first time - so there is something like a "one click lag".
Therefore i think that the event comes up too late - when the grid has
already been initialized or somethink like that..:-(

That's it! The most rigorous approach seems to be like this:

In the edit_event, read the id of the data reord (CountryID). Refill the
Grid. Find the row containing the data record with the found ID. Set this
row in Edit mode. But it beats the purpose of ViewState and all..

Sorry for the long message

Cheers

Stamen

"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Stamen,

As long as your entries have a primary key I don't see how they could be
compromised. Of course any well designed database uses a primary key to make certain that a row is unique.

Are the Id's that you are referring to not primary keys?

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hallo Justin,

thanks for replying. What you propose however is exactly what I am doing:
The code below is not immune against database changes:

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack)
{
this.da.Fill(ds 1, "Countrys") ;
this.DataGrid1. DataBind();
}
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
this.da.Fill(ds 1, "Names");
DataGrid1.EditI temIndex = e.Item.ItemInde x;
DataGrid1.DataB ind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
Stamen,

Typically when doing an operation like this you wouldn't rebind the grid before the edit operation.

So, in the page load sub use:

If Not IsPostBack Then
'---Bind your grid here
End If

(Make certain that viewstate is turned on for the grid. This way you
don't have to rebind the grid.)

Then rebind the grid after you edit the data.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
> Hi all,
>
> I think there is an inherent problem with most examples on the internet > (with MSDN, too!) showing datagrid's databinding. Here is, how they look > like:
>
> =============== =========
> On Page_Load
> if !IsPostBack: BindGrid()
>
> On_Edit
> Set datagrid's EditItem to clicked item
> BindGrid
>
> void BindGrid()
> Fill DataSet through dataadapter
> DataGrid.DataBi nd()
> =============== =========
>
> Imagine a simple table "Names" with two columns: NameID and Name
>
> Your SQL Select Statement reads "SELECT NameID, Name FROM Names
ORDER BY > Name" and you have two records in it:
> ID=1, Name = "aaaa"
> ID=2, Name = "cccc"
>
> So, the first time you call the page, you get following grid:
> 1 "aaaa" edit-button
> 2 "cccc" edit-button
>
> during the time in which you are viewing this html page on your IE

someone
> inserts another record in the table: "ID=3, Name='bbbb'".
> Then you click the edit button of the second row into your grid (2
> "cccc") intending to edit the name "cccc". When you klick the edit

button,
> however, you get following grid:
> 1 "aaaa" edit-button
> 3 [bbbb] - updatable!!! Update-button, cancel-button
> 2 "cccc" edit-button
>
> I am sure, you ghet what the reason is. What is the best solution to

guard
> against this problem?
>
> Thank you for taking your time and understanding what I mean. I

thought
of
a
> logical solution which however does not work. In case a discussion

occur,
I
> will write about it.
>
> All best
>
> Stamen
>
>



Nov 17 '05 #7
Stamen,

In the example I emailed to you I forgot to tell you to also remove the
databind. Of course if you databind to an empty dataset your grid will be
blank.

You should be making certain that the datagrid itself has it's viewstate set
to true (as should any object it may be contained in such as a panel and the
page object.

Then your code should simply set that row to be editable:

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
DataGrid1.EditI temIndex = e.Item.ItemInde x;
}

Since the datagrid is now not being repopulated from the database it will
only contain the original data and thus no problem...

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hallo Justin,

thanks for replying. What you propose however is exactly what I am doing:
The code below is not immune against database changes:

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack)
{
this.da.Fill(ds 1, "Countrys") ;
this.DataGrid1. DataBind();
}
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
this.da.Fill(ds 1, "Names");
DataGrid1.EditI temIndex = e.Item.ItemInde x;
DataGrid1.DataB ind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
Stamen,

Typically when doing an operation like this you wouldn't rebind the grid
before the edit operation.

So, in the page load sub use:

If Not IsPostBack Then
'---Bind your grid here
End If

(Make certain that viewstate is turned on for the grid. This way you don't
have to rebind the grid.)

Then rebind the grid after you edit the data.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:uu******** ******@TK2MSFTN GP10.phx.gbl...
Hi all,

I think there is an inherent problem with most examples on the internet (with MSDN, too!) showing datagrid's databinding. Here is, how they look like:

=============== =========
On Page_Load
if !IsPostBack: BindGrid()

On_Edit
Set datagrid's EditItem to clicked item
BindGrid

void BindGrid()
Fill DataSet through dataadapter
DataGrid.DataBi nd()
=============== =========

Imagine a simple table "Names" with two columns: NameID and Name

Your SQL Select Statement reads "SELECT NameID, Name FROM Names ORDER BY Name" and you have two records in it:
ID=1, Name = "aaaa"
ID=2, Name = "cccc"

So, the first time you call the page, you get following grid:
1 "aaaa" edit-button
2 "cccc" edit-button

during the time in which you are viewing this html page on your IE
someone inserts another record in the table: "ID=3, Name='bbbb'".
Then you click the edit button of the second row into your grid (2
"cccc") intending to edit the name "cccc". When you klick the edit button, however, you get following grid:
1 "aaaa" edit-button
3 [bbbb] - updatable!!! Update-button, cancel-button
2 "cccc" edit-button

I am sure, you ghet what the reason is. What is the best solution to guard against this problem?

Thank you for taking your time and understanding what I mean. I

thought of
a
logical solution which however does not work. In case a discussion

occur,
I
will write about it.

All best

Stamen



Nov 17 '05 #8
Stamen,

In the example I emailed to you I forgot to tell you to also remove the
databind. Of course if you databind to an empty dataset your grid will be
blank.

You should be making certain that the datagrid itself has it's viewstate set
to true (as should any object it may be contained in such as a panel and the
page object. The datagrid should certainly re-populate itself from
viewstate. If it doesn't then something else is wrong with your code.

Then your code should simply set that row to be editable:

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
DataGrid1.EditI temIndex = e.Item.ItemInde x;
}

Since the datagrid is now not being repopulated from the database it will
only contain the original data and thus no problem...

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <no****@nospam. de> wrote in message
news:O%******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Justin,

the table has two Columns: CountryID and Country - the sorting is done on
Country not on CountryID, which of course is a primary key. The prblem of
this approach is that it expects when refilling the datagrid that all
records will come in the same order, what is quite an optimistic expectation in the general case.

I tried your proposition of not refilling the dataadapter - it does not work at all, as now data gets shown on the repost.

I had tried another approach:

On_Edit_Event
set editIndex=click edIndex
Exit

hoping that the grid gets reloaded from the ViewState. Unfortunately this
does not work for some reason: The first time i click [Edit], nothing
happens. The second time I click - the record enters edit-state wehich I
have clicked the first time - so there is something like a "one click lag". Therefore i think that the event comes up too late - when the grid has
already been initialized or somethink like that..:-(

That's it! The most rigorous approach seems to be like this:

In the edit_event, read the id of the data reord (CountryID). Refill the
Grid. Find the row containing the data record with the found ID. Set this
row in Edit mode. But it beats the purpose of ViewState and all..

Sorry for the long message

Cheers

Stamen

"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Stamen,

As long as your entries have a primary key I don't see how they could be
compromised. Of course any well designed database uses a primary key to

make
certain that a row is unique.

Are the Id's that you are referring to not primary keys?

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stamen Gortchev" <s.********@onv entis.de> wrote in message
news:OD******** ******@TK2MSFTN GP12.phx.gbl...
Hallo Justin,

thanks for replying. What you propose however is exactly what I am doing: The code below is not immune against database changes:

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack)
{
this.da.Fill(ds 1, "Countrys") ;
this.DataGrid1. DataBind();
}
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
this.da.Fill(ds 1, "Names");
DataGrid1.EditI temIndex = e.Item.ItemInde x;
DataGrid1.DataB ind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutf ortunate.com> schrieb im Newsbeitrag
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
> Stamen,
>
> Typically when doing an operation like this you wouldn't rebind the grid > before the edit operation.
>
> So, in the page load sub use:
>
> If Not IsPostBack Then
> '---Bind your grid here
> End If
>
> (Make certain that viewstate is turned on for the grid. This way you

don't
> have to rebind the grid.)
>
> Then rebind the grid after you edit the data.
>
> Sincerely,
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Stamen Gortchev" <s.********@onv entis.de> wrote in message
> news:uu******** ******@TK2MSFTN GP10.phx.gbl...
> > Hi all,
> >
> > I think there is an inherent problem with most examples on the

internet
> > (with MSDN, too!) showing datagrid's databinding. Here is, how they
look
> > like:
> >
> > =============== =========
> > On Page_Load
> > if !IsPostBack: BindGrid()
> >
> > On_Edit
> > Set datagrid's EditItem to clicked item
> > BindGrid
> >
> > void BindGrid()
> > Fill DataSet through dataadapter
> > DataGrid.DataBi nd()
> > =============== =========
> >
> > Imagine a simple table "Names" with two columns: NameID and Name
> >
> > Your SQL Select Statement reads "SELECT NameID, Name FROM Names

ORDER
BY
> > Name" and you have two records in it:
> > ID=1, Name = "aaaa"
> > ID=2, Name = "cccc"
> >
> > So, the first time you call the page, you get following grid:
> > 1 "aaaa" edit-button
> > 2 "cccc" edit-button
> >
> > during the time in which you are viewing this html page on your IE
someone
> > inserts another record in the table: "ID=3, Name='bbbb'".
> > Then you click the edit button of the second row into your grid (2
> > "cccc") intending to edit the name "cccc". When you klick the edit
button,
> > however, you get following grid:
> > 1 "aaaa" edit-button
> > 3 [bbbb] - updatable!!! Update-button, cancel-button
> > 2 "cccc" edit-button
> >
> > I am sure, you ghet what the reason is. What is the best solution

to guard
> > against this problem?
> >
> > Thank you for taking your time and understanding what I mean. I

thought
of
> a
> > logical solution which however does not work. In case a discussion
occur,
> I
> > will write about it.
> >
> > All best
> >
> > Stamen
> >
> >
>
>



Nov 17 '05 #9
"Stamen Gortchev" <no****@nospam. de> wrote in message
news:O%******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Justin,

the table has two Columns: CountryID and Country - the sorting is done on
Country not on CountryID, which of course is a primary key. The prblem of
this approach is that it expects when refilling the datagrid that all
records will come in the same order, what is quite an optimistic expectation in the general case.

I tried your proposition of not refilling the dataadapter - it does not work at all, as now data gets shown on the repost.

I had tried another approach:

On_Edit_Event
set editIndex=click edIndex
Exit


Try calling DataGrid.DataBi nd after you set EditItemIndex.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
Nov 17 '05 #10

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

Similar topics

1
4496
by: Jimmy | last post by:
Hi folks, I'm hoping someone has a suggestion to solve this. I've been using Visual Studio Enterprise 6 (just the VB6 part) on my Dell laptop (PIII-700) running Win Me for a few years now, with the original MSDN library installed. No problems. Anyway, now the laptop is staying at work, so I needed to install everything on my home PC, which runs Win 2000 Pro. Installed VS6 okay. Then installed MSDN, the original version out of the box,...
1
1372
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my case i have everything in string
12
387
by: Stamen Gortchev | last post by:
Hi all, I think there is an inherent problem with most examples on the internet (with MSDN, too!) showing datagrid's databinding. Here is, how they look like: ======================== On Page_Load if !IsPostBack: BindGrid()
9
1287
by: clintonG | last post by:
Simply a postulation but consider the following... // breaks when declared in content page that uses a MasterPage <img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" /> // must run as a web server control <img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" runat="server" /> However... When we want to change themes dynamically how do we modify the
5
1562
by: clintonG | last post by:
Neither MSDN code examples nor will function. Has anybody figured out how to use the 2.0 classes, methods and properties to dynamically create HTML in the HTML <head> element? I've burned through everything I could find using google. <%= Clinton Gallagher METROmilwaukee (sm) "A Regional Information Service" NET csgallagher AT metromilwaukee.com URL http://metromilwaukee.com/
1
1557
by: gerry | last post by:
I wrote up a couple of simple SiteMap providers based on the MSDN documentation and examples, in particular the AccessSiteMapProvider example found at http://msdn2.microsoft.com/en-us/library/ms178434.aspx I keep running into the same problem - the root node cannot be found. So I went back and tried the MSDN example exactly as it appears in the documentation ( or at least as exact as I could get - I did have to make 2 minor modifications...
7
1926
by: Tom | last post by:
By my estimate, greater than 90% of the online doco code does not work without additional coding effort. Fully working solutions are invaluable for the student. A guru's work measured in minutes can take a newb ages to duplicate. Imagine the improved teaching efficiency of being able to direct someone to a working solution! Gurus would not have to teach the same lesson repeatedly and their work would be more persistent. A picture is...
10
1760
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi Whenever I download MSDN examples and then try to build them It says 'Build skipped' and never builds them. Hence I can not run them. What am I doing wrong??? Cheers. Manj.
0
8197
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8589
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8287
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8443
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2573
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 we have to send another system
0
1438
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.