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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top