|
|
|
date: Tue, 8 Jul 2008 14:07:56 -0700,
group: microsoft.public.dotnet.framework.aspnet
back
RE: GridView update problem
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 "RowUpdating" 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_RowUpdating(object sender,
GridViewUpdateEventArgs 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:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL" <SAL@nospam.nospam>
>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
>
>
>
date: Wed, 09 Jul 2008 04:35:17 GMT
author: (Steven Cheng [MSFT])
Re: GridView update problem
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 objectdatasource 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]" wrote in message
news:e5Of00X4IHA.4688@TK2MSFTNGHUB02.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 "RowUpdating" 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_RowUpdating(object sender,
> GridViewUpdateEventArgs 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "SAL" <SAL@nospam.nospam>
>>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
>>
>>
>>
>
date: Wed, 9 Jul 2008 09:52:04 -0700
author: SAL am
Re: GridView update problem
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:
msdnmg@microsoft.com.
--------------------
>From: "SAL" <SAL@nospam.nospam>
>References:
>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 objectdatasource 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]" wrote in message
>news:e5Of00X4IHA.4688@TK2MSFTNGHUB02.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 "RowUpdating" 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_RowUpdating(object sender,
>> GridViewUpdateEventArgs e)
>> {
>> //e.Keys;
>> //e.NewValues;
>> // e.OldValues;
>> ..................
>> ======================
>>
>> If there is anything I omit, please feel free to let me know.
>>
>> Sincerely,
>>
date: Thu, 10 Jul 2008 03:16:53 GMT
author: (Steven Cheng [MSFT])
Re: GridView update problem
Steven,
I have sent a small project that exhibits this symptom.
S
"Steven Cheng [MSFT]" wrote in message
news:37vfutj4IHA.4056@TK2MSFTNGHUB02.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:
> msdnmg@microsoft.com.
>
>
> --------------------
>>From: "SAL" <SAL@nospam.nospam>
>>References:
>
>>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 objectdatasource 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]" wrote in message
>>news:e5Of00X4IHA.4688@TK2MSFTNGHUB02.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 "RowUpdating"
>>> 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_RowUpdating(object sender,
>>> GridViewUpdateEventArgs e)
>>> {
>>> //e.Keys;
>>> //e.NewValues;
>>> // e.OldValues;
>>> ..................
>>> ======================
>>>
>>> If there is anything I omit, please feel free to let me know.
>>>
>>> Sincerely,
>>>
>
date: Thu, 10 Jul 2008 10:31:34 -0700
author: SAL am
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 requiredFieldValidator 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
"ValidationGroup" for them so that they'll not affect the edit/update of
Gridview
==========
<asp:TextBox ID="txtDbsId"
..................ValidationGroup="Insert_Group"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1".....................
ValidationGroup="Insert_Group">*</asp:RequiredFieldValidator>
<asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Insert"
EnableViewState="False"
ValidationGroup="Insert_Group" />
============================
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 "RowUpdating" event, however, you've also add
the following code in "Rowcommand" event:
+===========
'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
' dsGISLayers.Update()
'End If
===================
If you want to manually do the updating, you only need the "RowUpdating"
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(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewUpdateEventArgs) 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 ObjectDataSource.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:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL" <SAL@nospam.nospam>
>References:
<O72hdQe4IHA.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]" wrote in message
>news:37vfutj4IHA.4056@TK2MSFTNGHUB02.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:
>> msdnmg@microsoft.com.
>>
>>
date: Fri, 11 Jul 2008 06:01:11 GMT
author: (Steven Cheng [MSFT])
Re: GridView update problem
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:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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 requiredFieldValidator 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
>"ValidationGroup" for them so that they'll not affect the edit/update of
>Gridview
>==========
> <asp:TextBox ID="txtDbsId"
>..................ValidationGroup="Insert_Group"></asp:TextBox>
>
> <asp:RequiredFieldValidator
>ID="RequiredFieldValidator1".....................
>
>ValidationGroup="Insert_Group">*</asp:RequiredFieldValidator>
>
>
> <asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Insert"
>EnableViewState="False"
> ValidationGroup="Insert_Group" />
>============================
>
>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 "RowUpdating" event, however, you've also add
>the following code in "Rowcommand" event:
>
>+===========
>
> 'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
> ' dsGISLayers.Update()
> 'End If
>===================
>
>If you want to manually do the updating, you only need the "RowUpdating"
>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(ByVal sender As Object, ByVal
e
>As System.Web.UI.WebControls.GridViewUpdateEventArgs) 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 ObjectDataSource.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:
>msdnmg@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti
f
>ications.
>
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>--------------------
>>From: "SAL" <SAL@nospam.nospam>
>>References:
> <O72hdQe4IHA.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]" wrote in message
>>news:37vfutj4IHA.4056@TK2MSFTNGHUB02.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:
>>> msdnmg@microsoft.com.
>>>
>>>
>
>
date: Tue, 15 Jul 2008 10:08:37 GMT
author: (Steven Cheng [MSFT])
Re: GridView update problem
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]" wrote in message
news:JjzgFLm5IHA.6088@TK2MSFTNGHUB02.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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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 requiredFieldValidator 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
>>"ValidationGroup" for them so that they'll not affect the edit/update of
>>Gridview
>>==========
>> <asp:TextBox ID="txtDbsId"
>>..................ValidationGroup="Insert_Group"></asp:TextBox>
>>
>> <asp:RequiredFieldValidator
>>ID="RequiredFieldValidator1".....................
>>
>>ValidationGroup="Insert_Group">*</asp:RequiredFieldValidator>
>>
>>
>> <asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Insert"
>>EnableViewState="False"
>> ValidationGroup="Insert_Group" />
>>============================
>>
>>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 "RowUpdating" event, however, you've also add
>>the following code in "Rowcommand" event:
>>
>>+===========
>>
>> 'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
>> ' dsGISLayers.Update()
>> 'End If
>>===================
>>
>>If you want to manually do the updating, you only need the "RowUpdating"
>>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(ByVal sender As Object, ByVal
> e
>>As System.Web.UI.WebControls.GridViewUpdateEventArgs) 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 ObjectDataSource.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:
>>msdnmg@microsoft.com.
>>
>>==================================================
>>Get notification to my posts through email? Please refer to
>>http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti
> f
>>ications.
>>
>>==================================================
>>This posting is provided "AS IS" with no warranties, and confers no
>>rights.
>>
>>--------------------
>>>From: "SAL" <SAL@nospam.nospam>
>>>References:
>> <O72hdQe4IHA.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]" wrote in message
>>>news:37vfutj4IHA.4056@TK2MSFTNGHUB02.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:
>>>> msdnmg@microsoft.com.
>>>>
>>>>
>>
>>
>
date: Tue, 15 Jul 2008 11:17:29 -0700
author: SAL am
Re: GridView update problem
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]" wrote in message
news:SsXNNux4IHA.1624@TK2MSFTNGHUB02.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 requiredFieldValidator 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
> "ValidationGroup" for them so that they'll not affect the edit/update of
> Gridview
> ==========
> <asp:TextBox ID="txtDbsId"
> ..................ValidationGroup="Insert_Group"></asp:TextBox>
>
> <asp:RequiredFieldValidator
> ID="RequiredFieldValidator1".....................
>
> ValidationGroup="Insert_Group">*</asp:RequiredFieldValidator>
>
>
> <asp:Button ID="btnAdd" runat="server" Text="Add" CommandName="Insert"
> EnableViewState="False"
> ValidationGroup="Insert_Group" />
> ============================
>
> 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 "RowUpdating" event, however, you've also add
> the following code in "Rowcommand" event:
>
> +===========
>
> 'ElseIf e.CommandName = "Update" AndAlso Page.IsValid Then
> ' dsGISLayers.Update()
> 'End If
> ===================
>
> If you want to manually do the updating, you only need the "RowUpdating"
> 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(ByVal sender As Object, ByVal e
> As System.Web.UI.WebControls.GridViewUpdateEventArgs) 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 ObjectDataSource.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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "SAL" <SAL@nospam.nospam>
>>References:
> <O72hdQe4IHA.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]" wrote in message
>>news:37vfutj4IHA.4056@TK2MSFTNGHUB02.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:
>>> msdnmg@microsoft.com.
>>>
>>>
>
date: Tue, 15 Jul 2008 12:47:10 -0700
author: SAL am
Re: GridView update problem
You're welcome.
If you need any further help on this later, 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:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL" <SAL@nospam.nospam>
>Subject: Re: GridView update problem
>Date: Wed, 16 Jul 2008 10:39:42 -0700
>
>Okay.
>
>Thanks so much for you support.
>
>SAL
>
>
>"Steven Cheng [MSFT]" wrote in message
>news:aRe7r9u5IHA.4056@TK2MSFTNGHUB02.phx.gbl...
>> 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:
>> msdnmg@microsoft.com.
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> --------------------
>>>From: "SAL" <SAL@nospam.nospam>
>>>References:
>> <O72hdQe4IHA.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
>>>>>
>>
>
>
>
date: Thu, 17 Jul 2008 06:03:56 GMT
author: (Steven Cheng [MSFT])
|
|