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

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.DataBind()
========================

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 1879
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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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.DataBind()
========================

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(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.da.Fill(ds1, "Countrys");
this.DataGrid1.DataBind();
}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.da.Fill(ds1, "Names");
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutfortunate.com> schrieb im Newsbeitrag
news:eN**************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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.DataBind()
========================

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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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***********@surfcontrol.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.********@onventis.de> wrote in message
news:OD**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.da.Fill(ds1, "Countrys");
this.DataGrid1.DataBind();
}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.da.Fill(ds1, "Names");
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutfortunate.com> schrieb im Newsbeitrag
news:eN**************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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.DataBind()
========================

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*************@TK2MSFTNGP09.phx.gbl...
"Stamen Gortchev" <s.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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***********@surfcontrol.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=clickedIndex
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*****@aboutfortunate.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:OD**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.da.Fill(ds1, "Countrys");
this.DataGrid1.DataBind();
}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.da.Fill(ds1, "Names");
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutfortunate.com> schrieb im Newsbeitrag
news:eN**************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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.DataBind()
> ========================
>
> 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_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
}

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.********@onventis.de> wrote in message
news:OD**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.da.Fill(ds1, "Countrys");
this.DataGrid1.DataBind();
}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.da.Fill(ds1, "Names");
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutfortunate.com> schrieb im Newsbeitrag
news:eN**************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:uu**************@TK2MSFTNGP10.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.DataBind()
========================

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_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
}

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%****************@TK2MSFTNGP11.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=clickedIndex
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*****@aboutfortunate.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
news:OD**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.da.Fill(ds1, "Countrys");
this.DataGrid1.DataBind();
}
}

private void DataGrid1_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.da.Fill(ds1, "Names");
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}

What do you think about it?

Thanks
Stamen
"S. Justin Gengo" <sj*****@aboutfortunate.com> schrieb im Newsbeitrag
news:eN**************@TK2MSFTNGP10.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.********@onventis.de> wrote in message
> news:uu**************@TK2MSFTNGP10.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.DataBind()
> > ========================
> >
> > 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%****************@TK2MSFTNGP11.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=clickedIndex
Exit


Try calling DataGrid.DataBind after you set EditItemIndex.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #10
"Stamen Gortchev" <no****@nospam.de> wrote in message
news:OL**************@TK2MSFTNGP12.phx.gbl...
John,

an example of Datagrid using can be found at:

http://msdn.microsoft.com/library/en...asp?frame=true

Stamen,

I took a look at that link, you're correct - that's a bug.

I submitted the issue to Microsoft by clicking the "feedback" link at the
bottom of the page. I got a response saying they'll look into correcting it
in future documentation. I was also told that the same pattern is used in
several places in the documentation and in the QuickStarts, and that the
issue will be raised for both.

I've had good response from the Microsoft Documentation and Training people
when I've commented on the MSDN documentation. I've always received a
prompt, courteous and even intelligent response. I haven't seen the results
in the documentation yet, but I'll be checking when the 2.0 documentation
comes out. : -)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #11

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

Similar topics

1
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...
1
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...
12
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...
9
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...
5
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...
1
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...
7
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...
10
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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...

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.