469,945 Members | 2,167 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

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

Aug 13 '07 #1
3 7276
On Aug 13, 11:42 am, Joey <joey.pow...@topscene.comwrote:
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?

Aug 13 '07 #2
On Aug 13, 12:21 pm, Joey <joey.pow...@topscene.comwrote:
On Aug 13, 11:42 am, Joey <joey.pow...@topscene.comwrote:
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/6...64fa1b339.aspx

Thanks, Bipin!

Aug 13 '07 #3
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

Aug 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John A Grandy | last post: by
2 posts views Thread by VB Programmer | last post: by
2 posts views Thread by ruthie | last post: by
1 post views Thread by =?Utf-8?B?UGF1bA==?= | last post: by
malav123
2 posts views Thread by malav123 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.