Select button in datagrid

J

Jeronimo Bertran

I have created a datagrid with a select button so that a user can select a
particular row. I did this by setting the CommandName="select". And
everything works fine. I now want to a add a second button that first
selects the row clicked and then performs a second task with that row.

How can I achieve this?

Thanks,

Jeronimo Bertran
 
S

Steven Cheng[MSFT]

Hi Jeronimo,

Welcome to MSDN newsgroup. From your description, you want to add a custom
button column in a webform datagrid. When the user click that button, that
certain row will turn into select mode and also perform
some other operate, yes?

Would you provide some further description on the "a second task"? Is it a
serverside task or a clientside task? If a serverside task, is it possbile
that we perform it just in the DataGrid's ItemCommand event when fired by
the button clicked event?

Please feel free to let me know if you have any certain concern on this.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Jeronimo Bertran

Hi Steven,

The additional task is a server side task. But it is a different task that
the one performed when the select button is pressed.

Thanks


(e-mail address removed) (Steven Cheng[MSFT]) wrote in
 
S

Steven Cheng[MSFT]

Hi Jeronimo,

Thanks for your followup. Then, since the task the second button to do is a
serverside task, is it ok that we provide a helper function to do the work
and put the function in the ItemCommand event of the datagrid?
All the postback event raise by buttons(or other submit controls) in
datagridrow will fire the DataGrid's
ItemCommand event.

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Jeronimo Bertran

However, even if we use the ItemCommand Event, the clicked row is not
selected on the datagrid. I want to have the row selected and then perform
the additional task.


(e-mail address removed) (Steven Cheng[MSFT]) wrote in
 
S

Steven Cheng[MSFT]

Thanks for your reply Jeronimo,

AS for selecting a row, we need to set the SelectItemIndex and them rebind
the grid with the datasource. So when we want to both select a certain row
and perform some further operations, we should also rebind the grid with
the datasource(just like in SelectCommand) and then do that additional
task.
In addition, do you think it's possible that we register some client script
in the ItemCommand which used to post back the form again to do the
additional task? That means in the first post back(itemcommend) , we do row
selection, and in the second postback, we do the further task?

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Jeronimo Bertran

Steven,

Yes, we could register a client script for the ItemCommand... would the
commandName be "select" for this button as well? Could you elaborate on
that idea?

Thanks

(e-mail address removed) (Steven Cheng[MSFT]) wrote in
 
S

Steven Cheng[MSFT]

Hi Jeronimo,

Thanks for your followup. Yes, the commandName could be the same as the
"Select" button, but why would you do so since it'll make it
undistinguishable from the select button?
What I means in the last message is to put a button column in the
datagrid, the commandName of the button be set to another value rather than
the "Select" , then when the button is clicked, the page is posteback and
in the ItemCommand event, we register a script block which will post back
the page again , so that we can do the additional works. (such as
document.forms[0].submit()) or call the auto generated __doPostBack)

How do you think of this?

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Jeronimo Bertran

(e-mail address removed) (Steven Cheng[MSFT]) wrote in



Thanks Steven, I will give it a try.
 
S

Steven Cheng[MSFT]

You're welcome.

If there is any further questions, please feel free to post here.
Good Luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top