Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Gridview pressing Edit do not show any editable editbox in grid, while delete works fine

Reply
Thread Tools

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

 
 
qa4ever
Guest
Posts: n/a
 
      04-15-2008
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

 
Reply With Quote
 
 
 
 
Stan
Guest
Posts: n/a
 
      04-16-2008
On 15 Apr, 15:38, "qa4ever" <qa4e...@gmail.com> wrote:
> 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.
 
Reply With Quote
 
 
 
 
qa4ever
Guest
Posts: n/a
 
      04-16-2008
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

"qa4ever" <> wrote in message
news:...
> 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


 
Reply With Quote
 
Stan
Guest
Posts: n/a
 
      04-16-2008
On 16 Apr, 21:18, "qa4ever" <qa4e...@gmail.com> wrote:
> 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
>
> "qa4ever" <qa4e...@gmail.com> wrote in message
>
> news:...
>
>
>
> > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No editbox () functionality in python-dialog module? Harishankar Python 0 03-31-2010 08:16 AM
Editable TextBox without Edit Mode in Gridview mbonney ASP .Net 0 09-10-2008 03:38 PM
AJAX app will not make call on Safari and FireFox, works fine on Internet Explorer, any ideas? JDeats ASP .Net 2 09-11-2007 10:20 PM
GridView edit validation, edit dropdown list, delete popup confirm =?Utf-8?B?a2Vu?= ASP .Net 1 01-23-2006 12:51 PM
Putting cursor at end of EditBox MPBroida C++ 5 10-25-2003 01:00 AM



Advertisments