471,571 Members | 1,056 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,571 software developers and data experts.

Help with Gridview and Updating

Hi,
I have a gridview which I added a

<asp:CommandField EditText="E" CancelText="C" UpdateText="U"
ButtonType="Link" ShowEditButton="True" />

my gridview looks like this

<asp:GridView ID="GridView1" runat="server" OnRowEditing="RowEdit"
OnRowCancelingEdit="RowCancel" OnRowUpdating="RowUpdating"...
<Columns>

...

<asp:BoundField DataField="prodid" HeaderText="prodid"
ReadOnly="true" ></asp:BoundField>
<asp:BoundField DataField="quantity"
HeaderText="Quantity">

<asp:CommandField EditText="E" CancelText="C"
UpdateText="U" ButtonType="Link" ShowEditButton="True" />

</Columns>

</asp:GridView>

First issue ...I have to click twice on "E" before the Gridview kicks into
Editing mode. (Note the Gridview is enclosed in an Ajax updatepanel).

Second...most important is, when the gridview is in editing mode I see the
textbox on the quantity column but it's empty. I don't see the original
value. When I enter a new value and click on the "U" for updating I get the
error

Object reference not set to an instance of an object. in my code

Protected Sub RowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)

With item
...
.Quantity = CType(r.Cells(9).FindControl(0),
TextBox).Text 'r.Cells <-here
End With

Any ideas please. I can seem to find any samples on using the Editing in
Gridview.

Thanks
Jan 30 '07 #1
1 4583
On Jan 30, 1:55 pm, Chris <C...@discussions.microsoft.comwrote:
Hi,
I have a gridview which I added a

<asp:CommandField EditText="E" CancelText="C" UpdateText="U"
ButtonType="Link" ShowEditButton="True" />

my gridview looks like this

<asp:GridView ID="GridView1" runat="server" OnRowEditing="RowEdit"
OnRowCancelingEdit="RowCancel" OnRowUpdating="RowUpdating"...
<Columns>

...

<asp:BoundField DataField="prodid" HeaderText="prodid"
ReadOnly="true" ></asp:BoundField>
<asp:BoundField DataField="quantity"
HeaderText="Quantity">

<asp:CommandField EditText="E" CancelText="C"
UpdateText="U" ButtonType="Link" ShowEditButton="True" />

</Columns>

</asp:GridView>

First issue ...I have to click twice on "E" before the Gridview kicks into
Editing mode. (Note the Gridview is enclosed in an Ajax updatepanel).

Second...most important is, when the gridview is in editing mode I see the
textbox on the quantity column but it's empty. I don't see the original
value. When I enter a new value and click on the "U" for updating I get the
error

Object reference not set to an instance of an object. in my code

Protected Sub RowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)

With item
...
.Quantity = CType(r.Cells(9).FindControl(0),
TextBox).Text 'r.Cells <-here
End With

Any ideas please. I can seem to find any samples on using the Editing in
Gridview.

Thanks
Not sure exactly what it is you are trying to do but this site has a
lot of good examples

http://gridviewguy.com/

Jan 31 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Brian McClellan | last post: by
3 posts views Thread by pblack9455 | last post: by
4 posts views Thread by =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post: by
11 posts views Thread by SAL | last post: by
reply views Thread by BizWeb | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

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.