Gridview pressing Edit do not show any editable editbox in grid, while delete works fine

Q

qa4ever

Hi Gridview gurus

I got a Gridview that is populated from Datatable, held in a Session.
Pressing delete successfully deletes the row.

Problem is that pressing Edit, no expected editbox apear instead nothing
happens except for my RowEditingBasket event handler is called and I can
see the value of the gridview that I hoped now had a editobox enabling
editing.

protected void RowEditingBasket(object sender, GridViewEditEventArgs e)
{
String newQuantity =
GridViewBasket.Rows[e.NewEditIndex].Cells[4].Text;


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<asp:GridView ID="GridViewBasket" runat="server"
AutoGenerateDeleteButton="true"
autogeneratecolumns="true"
autogenerateeditbutton="true"
datakeynames="IDRow"
onrowupdating="RowUpdatingBasket"
onrowdeleting="RowDeletingBasket"
Caption="Your basket contain the following items:"
onrowediting="RowEditingBasket" >
<EditRowStyle BackColor="Yellow" />
<AlternatingRowStyle BorderStyle="Inset" />

</asp:GridView>


I.e delete works fine but not updating /editing the same
public void DoRowDeletingBasket ( object o, GridViewDeleteEventArgs e)
{
dt = (DataTable)Session["data"];
dt.Rows.RemoveAt(e.RowIndex);
dt.AcceptChanges(); //commit
Session["data"] = dt;


Thank you,
QA4ever
 
S

Stan

Hi Gridview gurus

I got a Gridview that is populated from Datatable, held in a  Session.
Pressing delete successfully deletes the row.

Problem is that pressing Edit,  no expected editbox apear instead nothing
happens except for my  RowEditingBasket event handler is called and I can
see the value of the gridview that I hoped now had a editobox enabling
editing.

protected void RowEditingBasket(object sender, GridViewEditEventArgs e)
    {
                String newQuantity =
GridViewBasket.Rows[e.NewEditIndex].Cells[4].Text;

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

    <asp:GridView ID="GridViewBasket" runat="server"
    AutoGenerateDeleteButton="true"
    autogeneratecolumns="true"
    autogenerateeditbutton="true"
    datakeynames="IDRow"
    onrowupdating="RowUpdatingBasket"
    onrowdeleting="RowDeletingBasket"
    Caption="Your basket contain the following items:"
    onrowediting="RowEditingBasket"  >
    <EditRowStyle BackColor="Yellow" />
    <AlternatingRowStyle BorderStyle="Inset" />

    </asp:GridView>

I.e delete works fine but not updating /editing the same
    public void DoRowDeletingBasket ( object o, GridViewDeleteEventArgs e)
    {
        dt = (DataTable)Session["data"];
        dt.Rows.RemoveAt(e.RowIndex);
        dt.AcceptChanges();  //commit
        Session["data"] = dt;

Thank you,
QA4ever

From information given cannot tell cause of problem is but even if it
did work newQuantity will be wrong value. RowEditing event occurs
before edit row appears not afterward.
 
Q

qa4ever

Hi gurus!

I have now got a bit further.

The Edit editbox apears and having pressed Update I see gui change back to
a static text (ie the editbox disapere) .

However in both eventhandlers for RowUpdating and RowUpdated both
e.NewValues and OldValues are empty !

Any Guess what's wrong? Do I need to bind the column "Quantity" to get the
value after updating? If so where and when?

Strange that the RowDeleting.... works perfect, I had guessed updating thru
the gridview would be more tricky than deleting, but this is ridiculous.

Thanks!,
QA4Ever
 
S

Stan

Hi gurus!

I have now got a bit further.

The Edit editbox apears and  having pressed Update I see gui change backto
a static text (ie the editbox disapere) .

However in both eventhandlers for RowUpdating and RowUpdated       both
e.NewValues and OldValues are empty !

Any Guess what's wrong? Do I need to bind the column "Quantity" to get the
value after updating? If so where and when?

Strange that the RowDeleting.... works perfect, I had guessed updating thru
the gridview would be more tricky than deleting, but this is ridiculous.

Thanks!,
QA4Ever




Hi Gridview gurus
I got a Gridview that is populated from Datatable, held in a  Session.
Pressing delete successfully deletes the row.
Problem is that pressing Edit,  no expected editbox apear instead nothing
happens except for my  RowEditingBasket event handler is called and I can
see the value of the gridview that I hoped now had a editobox enabling
editing.
protected void RowEditingBasket(object sender, GridViewEditEventArgs e)
   {
               String newQuantity =
GridViewBasket.Rows[e.NewEditIndex].Cells[4].Text;
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
   <asp:GridView ID="GridViewBasket" runat="server"
   AutoGenerateDeleteButton="true"
   autogeneratecolumns="true"
   autogenerateeditbutton="true"
   datakeynames="IDRow"
   onrowupdating="RowUpdatingBasket"
   onrowdeleting="RowDeletingBasket"
   Caption="Your basket contain the following items:"
   onrowediting="RowEditingBasket"  >
   <EditRowStyle BackColor="Yellow" />
   <AlternatingRowStyle BorderStyle="Inset" />
   </asp:GridView>
I.e delete works fine but not updating /editing the same
   public void DoRowDeletingBasket ( object o, GridViewDeleteEventArgs e)
   {
       dt = (DataTable)Session["data"];
       dt.Rows.RemoveAt(e.RowIndex);
       dt.AcceptChanges();  //commit
       Session["data"] = dt;
Thank you,
QA4ever- Hide quoted text -

- Show quoted text -

Recommend the use of an ObjectDataSource in conjunction with a newly
declared class object. If not familiar look it up and learn how to use
it.

With that you can put all the data handling code in the class file
(i.e. create and maintain the DataTable stored in Session state). You
will need to write procedures for retrieving the table (select
method), updating and deleting rows using values as passed as
parameters but there will be no need to bother about event handlers or
getting data to and from the GridView. The ObjectDataSource will do
all that for you.

Good luck
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top