Would like to load a datagrid already in edit mode instead of having the user click the edit button

F

Frank Kurka

Now my asp.net datagrid shows an edit button and clicking it puts the datagrid in edit mode.

I would like to:

1) possilby load the page already in edit mode (implies some kind of OnLoad command to the datagrid to put it in edit mode before it is rendered and sent)

and

2) have a button outside the datagrid to initiate edit, update , etc. that does not require the button to have a datagrid as the parent (as the buttons inside the datagrid have).

Thanks in advance.
 
E

Elton Wang

Hi Frank,

It's not clear what your idea is.

What you mentioned inside button can invoke a specified
row (clicked) into edit state. So how do you specify which
row will be edited, especially you want to directly into
edit state from page load?

Hope you can give more detailed info about your idea.

Elton Wang
(e-mail address removed)

-----Original Message-----
Now my asp.net datagrid shows an edit button and clicking
it puts the datagrid in edit mode.
I would like to:

1) possilby load the page already in edit mode (implies
some kind of OnLoad command to the datagrid to put it in
edit mode before it is rendered and sent)
and

2) have a button outside the datagrid to initiate edit,
update , etc. that does not require the button to have a
datagrid as the parent (as the buttons inside the datagrid
have).
 
F

Frank Kurka

Well, there are 2 ideas here (both related to datagrid)

1) when a datagrid is built and loaded .. it is already in a "normal state".
You can add template edit with a button that the user can click to reload it
and rerender it in an edit state, but only after the user clicks on it.

I would like the datagrid loaded already in an edit state (like forms used
to do) ..as if the user had clicked edit alredy, before the page even loaded
so the user can do ahead and edit whenhe firsty sees it without having to
click the edit button first.

2) For the second idea .. I am just trying to move the edit (or update)
button outside the datagrid so it canappear somehwere else on the page ...

This is really about single record datagrids (and datalists) where there is
only one record involved ... no need for one per row (only one involved)

Hope this is clearer .. hard to explain sometimes ...
 
E

Elton Wang

If I understand correctly, you actually want a Multi-row
updating datagrid. In that case you can directly put
textbox, dropdownlist, and checkbox in TemplateColumn +
ItemTemplate tags (except key column). So the whole
datagrid is editable. Then you have a normal button on
page to implement updating operation.

HTH

Elton Wang
 
F

Frank Kurka

Nope .. that is not it ... Not multi row at all - single row.

In the case you are describing ....the drop down list box is still within
the geographic region of the datagrid.

That means the buttons will be within the datagrid not somewhere else on the
page.

I want to put the update, edit, etc buttons somewhere else on the page -
outside of the datagrid and its template area.

The code for update, etc .. is looking for object and event parameters that
are not available to buttons and links outside of the datagrid, but are
provided by buttons within the datagrid.

The other case, is realted in that .. I want to in effect "simulate" that
the edit button was pressed on the pages initial load .. which i'm assuming
could be done if I can get the propre reference to the datagrid and call
some method to put it in the "edit sate"

Is that any clearer?

(Thanks for trying)
 
E

Elton Wang

OK single row.

So suppose there are 10 rows in a datagrid. When in page
load, how do you know which row the user wants to select
to edit, before the user click any button?

Although there is only one row involved, the important
question is that which row is involved.

What I mentioned dropdownlist is not for row selection.
It's the same as textbox for a field data, only limit the
data in select range.

HTH

Elton Wang
 
F

Frank Kurka

Hi:

You can control how many rows are involved by carefully constucting the sql
that pulls the row from the database .. so that there is only ... or you can
make a datagrid using a datasource that only has 1 record .. that is not the
real issue so let's not get hung up on that. Also, the button issue is
involved for both datagird (1 to n records) or datalist (1 to n records) .
the template buttons for edit, update, cancel etc are geographically located
within the confines of the datagrid and not necessarily where a designer
would wnat them (say all on the left)

Becasuse the standard code that supports edit, update, save, etc expects
that the ovject and event are passed in .. any button outside the data
object can't pass that info in .. so you can't call the routines from a
button outside the data container.

The solution should be to somehow get a reference to the datagrid, or to
hidden versions fo the buttons, or something .. but I haven't been able to
figure it out.


The other idea, of rendering the datagrid already in edit mode is similar ..
acting as if the user already clicked on edit before loading the page.
 
I

Ian

The long and short of it is that, prior to the initial DataBind, you
need to figure out which row you want to be in edit mode. Once you
know that simply set the DataGrid.EditItemIndex to the index of that
row and DataBind() and voila, that row will be in Edit mode.

Ian
 
M

Matt

Frank Kurka said:
Hi:

You can control how many rows are involved by carefully constucting the
sql
that pulls the row from the database .. so that there is only ... or you
can
make a datagrid using a datasource that only has 1 record .. that is not
the
real issue so let's not get hung up on that. Also, the button issue is
involved for both datagird (1 to n records) or datalist (1 to n records) .
the template buttons for edit, update, cancel etc are geographically
located
within the confines of the datagrid and not necessarily where a designer
would wnat them (say all on the left)

[trim]

Then just before you call:


DataGrid1.DataSouce = mycollection;

//this is the line you need
DataGrid1.EditItemIndex = 0; //could be 1 instead, but guessing 0 since
index.

DataGrid1.DataBind();


If you've been building your datagrid solely using point and click you have
to have a hunt in the code behind for where databind() occurs, expand the
web generated code bit.
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top