473,466 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 7411
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John A Grandy | last post by:
I'm not using SqlDataSource or ObjectDataSource. I'm handling events , similar to approach commonly used in 1.1. DataGrid. My question is : How do I configure a GridView's edit mode row format ?...
2
by: VB Programmer | last post by:
I have a gridview control with several data fields. When the user clicks 'edit' for the row I want the user to be able to edit a particular text field. Under that 'edit' textbox is a button. ...
0
by: nitinp | last post by:
I am facing the problem in editing records in child gridview which i have placed in the parent gridview's cell. I have bound both parent and child with different sqlDataSource objects. I have...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
0
by: jmacduff | last post by:
Big question: How to enable edit/update commands to work when setting the sqldatasource select command from code behind. Details: I have a GridView using a sqldatasouce with the select and...
2
by: ruthie | last post by:
Hi, I have a gridview with edit option. If the user chooses to edit the row and then press the Cancel button - I would like the focus to return to the chosen row. Someone has any idea how to...
1
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a table with a field with a bit datatype. I use a gridview to edit that a row in that table. I use SQLDataSource and enable editbutton property to get a link to edit the row. That all...
3
by: ASPnewb1 | last post by:
I am currently filling a dataTable then adding this table to a dataset, setting the dataset to the Gridview's datasource. If I set the Gridview to generate columns automatically it will fill the...
2
malav123
by: malav123 | last post by:
hi, I am using gridview control in asp.net.... i want to edit the gridview as like spreadsheet allows to edit... so is there any way to edit the gridview just like table...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.