Solved

Datagrid footer - basic question

Posted on 2004-10-07
4
410 Views
Last Modified: 2008-03-17
I have seen a few articles on adding a "add new record" sort of feature in the footer of a datagrid.  I would like to know if it is possible to do the following:

Have an EditCommandColumn and a DeleteCommandColumn that has a footer template so that I can add the "add" button in the footer of the EditCommandColumn and a "Cancel" button in the footer of the DeleteCommandColumn.

I attempted to do this by turning the Edit/DeleteCommandColumns into Template columns and then the appropriate commandevents stopped working and became intercepted by the itemcommand event.  Here is what I did for the edit command column:

                                        <asp:TemplateColumn>
                                    <ItemTemplate>
                                          <asp:LinkButton runat="server" Text="Edit" CommandName="Edit" CausesValidation="false"></asp:LinkButton>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                          <asp:linkbutton ID="lnkAdd" Runat="server" Text="Add" CommandName="Add"></asp:linkbutton>
                                    </FooterTemplate>
                                    <EditItemTemplate>
                                          <asp:LinkButton runat="server" Text="Update" CommandName="Update"></asp:LinkButton>&nbsp;
                                          <asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false"></asp:LinkButton>
                                    </EditItemTemplate>
                              </asp:TemplateColumn>

Thanks for your help!  I've been working on this for days and it's driving me nuts!!
0
Comment
Question by:tsbathe
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 300 total points
ID: 12253159
Are you sure you just aren't misunderstanding how DataGrid events are fired? The ItemCommand event of the datagrid gets fired for every event, even when you click edit/update/cancel/delete.  Then the datagrid fires events for Update/Cancel/Delete Commands.  If you don't want anything to happen in the ItemCommand event, you have to write checks to do this.  Usually I find this works in the ItemCommand events.

If e.CommandName = "Select" Then
  'do something other than update/edit/delete/cancel
End IF
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12253168
so what happens now...

edit and delete don't fire....or any exception...
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12253178
yeah u have to use e.CommandName.....

0
 

Author Comment

by:tsbathe
ID: 12254480
YES!!!  You are right!!!!!  I did not understand that, thank you so much!!!!!!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question