|
|
|
start date: Mon, 13 Aug 2007 09:42:21 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Joey
|
|
2
Joey
|
|
3
Joey
|
|
4
Phil H
|
Why Can't I Edit My GridView?
asp.net 2.0
VS2005
C#
In my web app I added a gridview and then manually configured
boundcolumns, for an in-session dataset to act as a datasource. Then I
added an Edit commandfield. When I run the page, in each row in the
gridview I see the data and the Edit and Delete links just fine. But
when I click an edit link, the post posts back and nothing else
happens...I do not get textboxes/checkboxes for the columns in the
grid. Each of these columns has its ReadOnly property set to False, so
what's going on here?
JP
Date:Mon, 13 Aug 2007 09:42:21 -0700
Author:
|
Re: Why Can't I Edit My GridView?
On Aug 13, 11:42 am, Joey wrote:
> asp.net 2.0
> VS2005
> C#
>
> In my web app I added a gridview and then manually configured
> boundcolumns, for an in-session dataset to act as a datasource. Then I
> added an Edit commandfield. When I run the page, in each row in the
> gridview I see the data and the Edit and Delete links just fine. But
> when I click an edit link, the post posts back and nothing else
> happens...I do not get textboxes/checkboxes for the columns in the
> grid. Each of these columns has its ReadOnly property set to False, so
> what's going on here?
>
> JP
Okay, I am getting frustrated because all the examples seem to show
how to do this with SqlDataSource or ObjectDataSource controls.
I simply have a dataset maintained in session state. When the page
loads, I bind the gridview to it and show the data. When I add to it,
I do an insert on the dataset and then rebind. When I delete, I handle
the grids RowDeleting event, remove the row from the dataset and then
rebind. This is the same way I did it in .net 1.1. It worked then and
it works now in 2.0. But for edits...
When I click the Edit link in any row in the grid, a postback occurs
and then nothing else happens. Nothing, no textboxes, no changeover of
the Edit links to Update and Cancel, etc...
If I handle the grids RowEditing event and then use
this.grdMyGrid.EditIndex = e.NewItemIndex.
The textboxes will appear, but then only after the SECOND time I click
Edit.
Does anyone know what is causing this?
Date:Mon, 13 Aug 2007 10:21:06 -0700
Author:
|
Re: Why Can't I Edit My GridView?
On Aug 13, 12:21 pm, Joey wrote:
> On Aug 13, 11:42 am, Joey wrote:
>
> > asp.net 2.0
> > VS2005
> > C#
>
> > In my web app I added a gridview and then manually configured
> > boundcolumns, for an in-session dataset to act as a datasource. Then I
> > added an Edit commandfield. When I run the page, in each row in the
> > gridview I see the data and the Edit and Delete links just fine. But
> > when I click an edit link, the post posts back and nothing else
> > happens...I do not get textboxes/checkboxes for the columns in the
> > grid. Each of these columns has its ReadOnly property set to False, so
> > what's going on here?
>
> > JP
>
> Okay, I am getting frustrated because all the examples seem to show
> how to do this with SqlDataSource or ObjectDataSource controls.
>
> I simply have a dataset maintained in session state. When the page
> loads, I bind the gridview to it and show the data. When I add to it,
> I do an insert on the dataset and then rebind. When I delete, I handle
> the grids RowDeleting event, remove the row from the dataset and then
> rebind. This is the same way I did it in .net 1.1. It worked then and
> it works now in 2.0. But for edits...
>
> When I click the Edit link in any row in the grid, a postback occurs
> and then nothing else happens. Nothing, no textboxes, no changeover of
> the Edit links to Update and Cancel, etc...
>
> If I handle the grids RowEditing event and then use
> this.grdMyGrid.EditIndex = e.NewItemIndex.
>
> The textboxes will appear, but then only after the SECOND time I click
> Edit.
>
> Does anyone know what is causing this?
Finally got it...
http://www.dotnetbips.com/articles/66852121-52f5-40b4-a077-eb464fa1b339.aspx
Thanks, Bipin!
Date:Mon, 13 Aug 2007 11:44:14 -0700
Author:
|
Re: Why Can't I Edit My GridView?
> Okay, I am getting frustrated because all the examples seem to show
> how to do this with SqlDataSource or ObjectDataSource controls.
>
> I simply have a dataset maintained in session state. When the page
> loads, I bind the gridview to it and show the data. When I add to it,
> I do an insert on the dataset and then rebind. When I delete, I handle
> the grids RowDeleting event, remove the row from the dataset and then
> rebind. This is the same way I did it in .net 1.1. It worked then and
> it works now in 2.0. But for edits...
Hi Joey
It may be that a Dataset as a datasource is not supported by automatic
databinding and mode changes like with the other types of datasource
you mention. If your source is a dataset then you need to create an
ObjectDataSource (i.e. add class file to your App_Code directory) and
place the code for maintaining it in there. Create some public
functions and methods that retrieve, update and insert data. Then add
an ObjectDatasource to your page and you will be able to configure the
select, insert, update and delete commands to link to them. Finally
link your Gridview to the ObjectDataSource and it will behave as
normal (you'll need to convert the columns to templates and manually
type in Eval("columnName") or Bind("ColumnName") for the databindings.
>
> When I click the Edit link in any row in the grid, a postback occurs
> and then nothing else happens. Nothing, no textboxes, no changeover of
> the Edit links to Update and Cancel, etc...
>
> If I handle the grids RowEditing event and then use
> this.grdMyGrid.EditIndex = e.NewItemIndex.
>
> The textboxes will appear, but then only after the SECOND time I click
> Edit.
>
> Does anyone know what is causing this?
That's because you have to re-execute Databind before the change to
EditIndex takes effect. It occurs automatically after the subsequest
postback hence the delay.
HTH
Phil Hall
Date:Mon, 13 Aug 2007 12:01:49 -0700
Author:
|
|
|