By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,273 Members | 1,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,273 IT Pros & Developers. It's quick & easy.

Help with Gridview and Updating

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.