Creating Datagrid Programatically

R

Raja Rajan J

Hello,

My query is simple. That is, I want to create a datagrid with data from
the database table and EditCommandColumn dynamically to edit, update and
cancel.

I have written event handlers for each of the events such as
EditCommand, UpdateCommand and CancelCommand.

What is happening is, the datagrid is shown properly with all the data
from the database table and the EditCommandColumn(Edit).

I have observed the following things.

1. When i click on edit, the seleted row is opening in the edit mode.
That is fine. That is, the event handler for the EditCommand is
invoked(ItemCommand event is called properly)

2. When I click on Update after editing the fields, the problem
starts here. That is, the ItemCommand event is fired with

ItemType = Item and
CommandName = Edit

The Actual value of the above said should be

ItemType = EditItem and
CommandName = Update

Because of the wrong values being set, it is calling the event handler
of the EditCommand again, instead of UpdateCommand event handler.

3. When I click on Cancel button, the ItemCommand event itself is not
fired.

The Actual value when ItemCommand is fired should have been the
following

ItemType = EditItem and
CommandName = Cancel

Since the ItemCommand event itself is not fired when Cancel
button is clicked, nothing is happening.

Note : The above said problems (2 and 3) is happening only when datagrid
is created programatically at runtime but not when designed at design
time.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top