473,695 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView update problem

SAL
Hello,
I have a Gridview control (.net 2.0) that I'm having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don't know if that's what's causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the Cancel
button takes the grid out of Edit mode. So, I don't get what the trick is
here.
I've enabled adding records via the FooterRow.
The reason I'm using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won't work...

Any ideas?

Thanks
SAL
Jul 8 '08 #1
11 6061
Hi SAL,

From your description, you're encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn't postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource's two-way databinding to automatically perform update or
you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdatin g" event
of the Gridview(ensure it get fired) and then check all the parameters (via
the event Argument parameter) to see whether the column data user entered
have been supplied correctly in the parameter collection:

=============== ====
protected void GridView1_RowUp dating(object sender,
GridViewUpdateE ventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
............... ....
=============== =======

If there is anything I omit, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "SAL" <SA*@nospam.nos pam>
Subject: GridView update problem
Date: Tue, 8 Jul 2008 14:07:56 -0700
>Hello,
I have a Gridview control (.net 2.0) that I'm having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don't know if that's what's causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the
Cancel
>button takes the grid out of Edit mode. So, I don't get what the trick is
here.
I've enabled adding records via the FooterRow.
The reason I'm using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won't work...

Any ideas?

Thanks
SAL
Jul 9 '08 #2
SAL
Hi Steven. As far as I can tell, it's not even doing a postback. If an event
was firing, I could at least manually update the record. It would be nice to
have it update itself however via two-way binding.

I've implemented two way binding via an objectdatasourc e which is bound to a
business object and the business object is using a table adapter that was
created using the designer.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:e5******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi SAL,

From your description, you're encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn't postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource's two-way databinding to automatically perform update or
you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdatin g" event
of the Gridview(ensure it get fired) and then check all the parameters
(via
the event Argument parameter) to see whether the column data user entered
have been supplied correctly in the parameter collection:

=============== ====
protected void GridView1_RowUp dating(object sender,
GridViewUpdateE ventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
............... ...
=============== =======

If there is anything I omit, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>From: "SAL" <SA*@nospam.nos pam>
Subject: GridView update problem
Date: Tue, 8 Jul 2008 14:07:56 -0700
>>Hello,
I have a Gridview control (.net 2.0) that I'm having trouble getting the
Update button to fire any kind of event or preforming the update. The
datatable is based on a join so I don't know if that's what's causing the
behavior or not. It seems like the Update button should at least do
something.
When the Edit button is clicked, the grid goes into Edit mode and the
Cancel
>>button takes the grid out of Edit mode. So, I don't get what the trick is
here.
I've enabled adding records via the FooterRow.
The reason I'm using a join is to allow sorting on the joined in field. I
know that I could drop kick the join, add in a template field and then
populate it during RowDataBound but then the sort won't work...

Any ideas?

Thanks
SAL

Jul 9 '08 #3
Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the update
button is put correctly(via edit/update command field). Is it reproable via
some simplified data source? You can send me a simplified copy so that I
can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
--------------------
>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5************ **@TK2MSFTNGHUB 02.phx.gbl>
>Subject: Re: GridView update problem
Date: Wed, 9 Jul 2008 09:52:04 -0700
>
Hi Steven. As far as I can tell, it's not even doing a postback. If an
event
>was firing, I could at least manually update the record. It would be nice
to
>have it update itself however via two-way binding.

I've implemented two way binding via an objectdatasourc e which is bound to
a
>business object and the business object is using a table adapter that was
created using the designer.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:e5******* *******@TK2MSFT NGHUB02.phx.gbl ...
>Hi SAL,

From your description, you're encountering some problem to get the update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn't postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you directly
use SqlDataSource's two-way databinding to automatically perform update
or
>you manually use code to update the database (when updating event fires)?
Generally, for such issue, I would first register the "RowUpdatin g" event
of the Gridview(ensure it get fired) and then check all the parameters
(via
the event Argument parameter) to see whether the column data user
entered
>have been supplied correctly in the parameter collection:

============== =====
protected void GridView1_RowUp dating(object sender,
GridViewUpdate EventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
.............. ....
============== ========

If there is anything I omit, please feel free to let me know.

Sincerely,
Jul 10 '08 #4
SAL
Steven,
I have sent a small project that exhibits this symptom.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:37******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the update
button is put correctly(via edit/update command field). Is it reproable
via
some simplified data source? You can send me a simplified copy so that I
can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
--------------------
>>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5************ **@TK2MSFTNGHUB 02.phx.gbl>
>>Subject: Re: GridView update problem
Date: Wed, 9 Jul 2008 09:52:04 -0700
>>
Hi Steven. As far as I can tell, it's not even doing a postback. If an
event
>>was firing, I could at least manually update the record. It would be nice
to
>>have it update itself however via two-way binding.

I've implemented two way binding via an objectdatasourc e which is bound to
a
>>business object and the business object is using a table adapter that was
created using the designer.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:e5****** ********@TK2MSF TNGHUB02.phx.gb l...
>>Hi SAL,

From your description, you're encountering some problem to get the
update
function in GridView to work, correct?

As for the Updating not work, do you means if you click "Update" button,
the page doesn't postback or the page does postback but the database
updating commands are not taking effect?

Also, how do you implement the edit/update in GridView, are you
directly
use SqlDataSource's two-way databinding to automatically perform update
or
>>you manually use code to update the database (when updating event
fires)?
Generally, for such issue, I would first register the "RowUpdatin g"
event
of the Gridview(ensure it get fired) and then check all the parameters
(via
the event Argument parameter) to see whether the column data user
entered
>>have been supplied correctly in the parameter collection:

============= ======
protected void GridView1_RowUp dating(object sender,
GridViewUpdat eEventArgs e)
{
//e.Keys;
//e.NewValues;
// e.OldValues;
............. .....
============= =========

If there is anything I omit, please feel free to let me know.

Sincerely,

Jul 10 '08 #5
Hi SAL,

I've received your email and performed some tests on the page you provided.

It seems you have many different code logic on the GridView+ ODataSource
editing/updating. I haven't looked deep into the database layer and after
some testing at the page/gridview layer, I found the following problems:

1. You have added some button and textbox in the GridView's Footer(of some
template fields) so as for inserting some records. However, since the
Textbox in insert template has requiredFieldVa lidator associated, when you
try editing/updating and submit update, the validation of the Insert
textbox will prevent it from postback the page. To address the problem, I
have used the following means:

#for TextBox, Validator and button in FooterTemplate, I set a separate
"ValidationGrou p" for them so that they'll not affect the edit/update of
Gridview
==========
<asp:TextBox ID="txtDbsId"
............... ....ValidationG roup="Insert_Gr oup"></asp:TextBox>

<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator1".. ............... ....

ValidationGroup ="Insert_Group" >*</asp:RequiredFie ldValidator>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="In sert"
EnableViewState ="False"
ValidationGroup ="Insert_Gro up" />
=============== =============

After that, the page can be submit correctly when we hit "update" button in
edit mode.
2. When the page postback to server-side, the Server-side validation
function will also query database to validate some input values. I'm not
sure the actual database schema and code logic, but you also need to check
this since if this fails, the updating event will not be reached.

3. You have registered the "RowUpdatin g" event, however, you've also add
the following code in "Rowcommand " event:

+===========

'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
' dsGISLayers.Upd ate()
'End If
=============== ====

If you want to manually do the updating, you only need the "RowUpdatin g"
event and you can get all the parameters from the parameters collection and
do your own ADO.NET code, after that call e.Cancel=True so as to prevent
the built-in updating code logic:

=============== =====
Protected Sub gvGISLayerEdit_ RowUpdating(ByV al sender As Object, ByVal e
As System.Web.UI.W ebControls.Grid ViewUpdateEvent Args) Handles
gvGISLayerEdit. RowUpdating

Response.Write( "<br/>gvGISLayerEdit _RowUpdating")

'get parameters from e.NewValues , e.OldValues, e.RowIndex
' and all TableAdapter to update

e.Cancel = True

End Sub
=============== ====

Simply call ObjectDataSourc e.Update will not take effect since you haven't
registered its "Updating" event and supply the necessary parameters for it.

BTW, for ASP.NET data accesing, you can refer to some good examples and
tutorial from the following site:

http://www.asp.net/learn/data-access/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5************ **@TK2MSFTNGHUB 02.phx.gbl<O72h dQe4IHA.5112
>Subject: Re: GridView update problem
Date: Thu, 10 Jul 2008 10:31:34 -0700
>
Steven,
I have sent a small project that exhibits this symptom.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:37******* *******@TK2MSFT NGHUB02.phx.gbl ...
>Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the
update
>button is put correctly(via edit/update command field). Is it reproable
via
some simplified data source? You can send me a simplified copy so that I
can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

Jul 11 '08 #6
Hi SAL,

How are you doing?

have you got any progress on this issue or does the information I provided
in last message help you some? If there is anything else need help, please
feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
even Cheng [MSFT])
>Organization : Microsoft
Date: Fri, 11 Jul 2008 06:01:11 GMT
Subject: Re: GridView update problem
>
Hi SAL,

I've received your email and performed some tests on the page you provided.

It seems you have many different code logic on the GridView+ ODataSource
editing/updating. I haven't looked deep into the database layer and after
some testing at the page/gridview layer, I found the following problems:

1. You have added some button and textbox in the GridView's Footer(of some
template fields) so as for inserting some records. However, since the
Textbox in insert template has requiredFieldVa lidator associated, when you
try editing/updating and submit update, the validation of the Insert
textbox will prevent it from postback the page. To address the problem,
I
>have used the following means:

#for TextBox, Validator and button in FooterTemplate, I set a separate
"ValidationGro up" for them so that they'll not affect the edit/update of
Gridview
==========
<asp:TextBox ID="txtDbsId"
.............. ....ValidationG roup="Insert_Gr oup"></asp:TextBox>

<asp:RequiredFi eldValidator
ID="RequiredFi eldValidator1". ............... .....

ValidationGrou p="Insert_Group ">*</asp:RequiredFie ldValidator>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="In sert"
EnableViewStat e="False"
ValidationGroup ="Insert_Gro up" />
============== ==============

After that, the page can be submit correctly when we hit "update" button
in
>edit mode.
2. When the page postback to server-side, the Server-side validation
function will also query database to validate some input values. I'm not
sure the actual database schema and code logic, but you also need to check
this since if this fails, the updating event will not be reached.

3. You have registered the "RowUpdatin g" event, however, you've also add
the following code in "Rowcommand " event:

+===========

'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
' dsGISLayers.Upd ate()
'End If
============== =====

If you want to manually do the updating, you only need the "RowUpdatin g"
event and you can get all the parameters from the parameters collection
and
>do your own ADO.NET code, after that call e.Cancel=True so as to prevent
the built-in updating code logic:

============== ======
Protected Sub gvGISLayerEdit_ RowUpdating(ByV al sender As Object, ByVal
e
>As System.Web.UI.W ebControls.Grid ViewUpdateEvent Args) Handles
gvGISLayerEdit .RowUpdating

Response.Write( "<br/>gvGISLayerEdit _RowUpdating")

'get parameters from e.NewValues , e.OldValues, e.RowIndex
' and all TableAdapter to update

e.Cancel = True

End Sub
============== =====

Simply call ObjectDataSourc e.Update will not take effect since you haven't
registered its "Updating" event and supply the necessary parameters for it.

BTW, for ASP.NET data accesing, you can refer to some good examples and
tutorial from the following site:

http://www.asp.net/learn/data-access/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microso ft.com.

============== =============== =============== ======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ault.aspx#noti
f
>ications.

============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5*********** ***@TK2MSFTNGHU B02.phx.gbl<O72 hdQe4IHA.5112
>>Subject: Re: GridView update problem
Date: Thu, 10 Jul 2008 10:31:34 -0700
>>
Steven,
I have sent a small project that exhibits this symptom.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:37****** ********@TK2MSF TNGHUB02.phx.gb l...
>>Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the
update
>>button is put correctly(via edit/update command field). Is it reproable
via
some simplified data source? You can send me a simplified copy so that
I
>>can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
>>suggestions about how we can improve the support we provide to you.
Please
>>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.


Jul 15 '08 #7
SAL
Steven,
I created a sample test project per your instructions and e-mailed it to
you. I have been waiting on you to check that code out and reply to me
directly I thought. Maybe not though. Did you not recieve the sample
project?

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:Jj******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi SAL,

How are you doing?

have you got any progress on this issue or does the information I provided
in last message help you some? If there is anything else need help, please
feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
even Cheng [MSFT])
>>Organizatio n: Microsoft
Date: Fri, 11 Jul 2008 06:01:11 GMT
Subject: Re: GridView update problem
>>
Hi SAL,

I've received your email and performed some tests on the page you
provided.

It seems you have many different code logic on the GridView+ ODataSource
editing/updating. I haven't looked deep into the database layer and after
some testing at the page/gridview layer, I found the following problems:

1. You have added some button and textbox in the GridView's Footer(of some
template fields) so as for inserting some records. However, since the
Textbox in insert template has requiredFieldVa lidator associated, when you
try editing/updating and submit update, the validation of the Insert
textbox will prevent it from postback the page. To address the problem,
I
>>have used the following means:

#for TextBox, Validator and button in FooterTemplate, I set a separate
"ValidationGr oup" for them so that they'll not affect the edit/update of
Gridview
==========
<asp:TextBox ID="txtDbsId"
............. .....Validation Group="Insert_G roup"></asp:TextBox>

<asp:RequiredFi eldValidator
ID="RequiredF ieldValidator1" ............... ......

ValidationGro up="Insert_Grou p">*</asp:RequiredFie ldValidator>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="In sert"
EnableViewSta te="False"
ValidationGroup ="Insert_Gro up" />
============= ===============

After that, the page can be submit correctly when we hit "update" button
in
>>edit mode.
2. When the page postback to server-side, the Server-side validation
function will also query database to validate some input values. I'm not
sure the actual database schema and code logic, but you also need to check
this since if this fails, the updating event will not be reached.

3. You have registered the "RowUpdatin g" event, however, you've also add
the following code in "Rowcommand " event:

+========== =

'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
' dsGISLayers.Upd ate()
'End If
============= ======

If you want to manually do the updating, you only need the "RowUpdatin g"
event and you can get all the parameters from the parameters collection
and
>>do your own ADO.NET code, after that call e.Cancel=True so as to prevent
the built-in updating code logic:

============= =======
Protected Sub gvGISLayerEdit_ RowUpdating(ByV al sender As Object, ByVal
e
>>As System.Web.UI.W ebControls.Grid ViewUpdateEvent Args) Handles
gvGISLayerEdi t.RowUpdating

Response.Write( "<br/>gvGISLayerEdit _RowUpdating")

'get parameters from e.NewValues , e.OldValues, e.RowIndex
' and all TableAdapter to update

e.Cancel = True

End Sub
============= ======

Simply call ObjectDataSourc e.Update will not take effect since you haven't
registered its "Updating" event and supply the necessary parameters for
it.

BTW, for ASP.NET data accesing, you can refer to some good examples and
tutorial from the following site:

http://www.asp.net/learn/data-access/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@micros oft.com.

============= =============== =============== =======
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ault.aspx#noti
f
>>ications.

============= =============== =============== =======
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>>From: "SAL" <SA*@nospam.nos pam>
References : <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5********** ****@TK2MSFTNGH UB02.phx.gbl<O7 2hdQe4IHA.5112
>>>Subject: Re: GridView update problem
Date: Thu, 10 Jul 2008 10:31:34 -0700
>>>
Steven,
I have sent a small project that exhibits this symptom.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:37***** *********@TK2MS FTNGHUB02.phx.g bl...
Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the
update
>>>button is put correctly(via edit/update command field). Is it reproable
via
some simplified data source? You can send me a simplified copy so that
I
>>>can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
>>>suggestion s about how we can improve the support we provide to you.
Please
>>>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.



Jul 15 '08 #8
SAL
Okay, I got your reply now. For some reason it didn't show up when I opened
up outlook express.

I'm doing the updating manually now and took out the code from rowcommand.

I made the changes you suggested for the ValidationGroup and the Update
button is now posting back.

I didn't quite understand what you were saying in #2 below however.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:Ss******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi SAL,

I've received your email and performed some tests on the page you
provided.

It seems you have many different code logic on the GridView+ ODataSource
editing/updating. I haven't looked deep into the database layer and after
some testing at the page/gridview layer, I found the following problems:

1. You have added some button and textbox in the GridView's Footer(of some
template fields) so as for inserting some records. However, since the
Textbox in insert template has requiredFieldVa lidator associated, when you
try editing/updating and submit update, the validation of the Insert
textbox will prevent it from postback the page. To address the problem,
I
have used the following means:

#for TextBox, Validator and button in FooterTemplate, I set a separate
"ValidationGrou p" for them so that they'll not affect the edit/update of
Gridview
==========
<asp:TextBox ID="txtDbsId"
............... ...ValidationGr oup="Insert_Gro up"></asp:TextBox>

<asp:RequiredFi eldValidator
ID="RequiredFie ldValidator1".. ............... ....

ValidationGroup ="Insert_Group" >*</asp:RequiredFie ldValidator>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="In sert"
EnableViewState ="False"
ValidationGroup ="Insert_Gro up" />
=============== =============

After that, the page can be submit correctly when we hit "update" button
in
edit mode.
2. When the page postback to server-side, the Server-side validation
function will also query database to validate some input values. I'm not
sure the actual database schema and code logic, but you also need to check
this since if this fails, the updating event will not be reached.

3. You have registered the "RowUpdatin g" event, however, you've also add
the following code in "Rowcommand " event:

+===========

'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
' dsGISLayers.Upd ate()
'End If
=============== ====

If you want to manually do the updating, you only need the "RowUpdatin g"
event and you can get all the parameters from the parameters collection
and
do your own ADO.NET code, after that call e.Cancel=True so as to prevent
the built-in updating code logic:

=============== =====
Protected Sub gvGISLayerEdit_ RowUpdating(ByV al sender As Object, ByVal e
As System.Web.UI.W ebControls.Grid ViewUpdateEvent Args) Handles
gvGISLayerEdit. RowUpdating

Response.Write( "<br/>gvGISLayerEdit _RowUpdating")

'get parameters from e.NewValues , e.OldValues, e.RowIndex
' and all TableAdapter to update

e.Cancel = True

End Sub
=============== ====

Simply call ObjectDataSourc e.Update will not take effect since you haven't
registered its "Updating" event and supply the necessary parameters for
it.

BTW, for ASP.NET data accesing, you can refer to some good examples and
tutorial from the following site:

http://www.asp.net/learn/data-access/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5************ **@TK2MSFTNGHUB 02.phx.gbl<O72h dQe4IHA.5112
>>Subject: Re: GridView update problem
Date: Thu, 10 Jul 2008 10:31:34 -0700
>>
Steven,
I have sent a small project that exhibits this symptom.

S

"Steven Cheng [MSFT]" <st*****@online .microsoft.comw rote in message
news:37****** ********@TK2MSF TNGHUB02.phx.gb l...
>>Thanks for your reply SAL,

That seems unexpected since the postback should work as long as the
update
>>button is put correctly(via edit/update command field). Is it reproable
via
some simplified data source? You can send me a simplified copy so that
I
can also test it on my side. My email is

"stcheng" + @ + "microsoft. com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you.
Please
>>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.


Jul 15 '08 #9
Thanks for your reply SAL,

I'm glad that the you got the email. For the #2 point you mentioned:

I just mean the Validation event of your validator control. Since you use
server-side validation, you need to make sure that the validation doesn't
work correctly and sometimes if the validation fails or not work correctly,
that may also prevent the other sequential postback event(such as Gridview
updating) work.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.====== =============== =============== ==============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL" <SA*@nospam.nos pam>
References: <Oh************ **@TK2MSFTNGP06 .phx.gbl>
<e5************ **@TK2MSFTNGHUB 02.phx.gbl<O72h dQe4IHA.511
>Subject: Re: GridView update problem
Date: Tue, 15 Jul 2008 12:47:10 -0700
>Okay, I got your reply now. For some reason it didn't show up when I
opened
>up outlook express.

I'm doing the updating manually now and took out the code from rowcommand.

I made the changes you suggested for the ValidationGroup and the Update
button is now posting back.

I didn't quite understand what you were saying in #2 below however.

S
>>>
Jul 16 '08 #10

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

Similar topics

3
6333
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
8
5034
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
0
2286
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web Setup Project and installed My Web Application on my Localhost and it works perfectly. When I install My Web Application on our “Production Server” it just doesn’t update the records on Edit mode!!!
3
19261
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create programatically a dataSet, set it as a DataSource for my GridView an add it to Session. 3. I want my users to be able to edit data displayed in GridView, so I added Edit command column. 4. When user clicks Edit, then I get the following error: "The GridView
0
3570
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
1
10402
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID" OnRowCreated="ContactHistoryGrid_RowCreated" CssClass="GridViewTable" GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True" AllowPaging="True"> <EmptyDataTemplate>
4
6073
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters are being populated. Integers are being passed as 0 and strings are empty regardless of what I changed them to in Edit mode on the GridView. My object method to perform the update:
4
9783
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the SqlDataSource to allow the GridView to be editable. I have now been able to get the GridView to display data...
11
4073
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved, CrtdUser and Date And Edit and Delete buttons
0
8619
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9112
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8824
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
7651
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 projectplanning, coding, testing, and deploymentwithout 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
6484
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...
0
4336
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4571
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2258
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
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.