Help with Gridview and Updating

G

Guest

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
 
D

Dave

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top