ASP.NET Gridview Question

I have the below column in a gridview control . I need to put different buttons in the column based on what state the gridview is in . However, right now I cannot seem to make the CommandField show up. I want to show the CommandField  if the gridview row is simply in display mode.  I am using the FooterTemplate  for data entry and the  EditTemplate for editing. How do I display the CommandField in the same column w/o the other buttons if the row is in display mode. Any help would be greatly appreciated.
										
<asp:TemplateField HeaderText="">
   <ItemTemplate>
      <asp:CommandField ValidationGroup="InsertHeUnitValEDIT" CausesValidation="true"  DeleteText="Delete"     EditText="Edit"  CancelText="Cancel" ShowCancelButton="true" ShowDeleteButton="true" ShowEditButton="true" ShowSelectButton="false" />
</ItemTemplate>

 <EditItemTemplate>
      <asp:Button ID="btnGetCorrespondingValuesEDIT" Visible="true" style="font-size: 6pt; width: 56px;" runat="server" Text="Get Values" OnClick="btnGetCorrespondingValuesEDIT_OnClick" Width="50px" Height="20px" />
</EditItemTemplate>

<FooterTemplate>
  <br />
<asp:Button ID="btnInsert" runat="Server" Text="Insert" style="font-size: 8pt; width: 56px;" CausesValidation="true" ValidationGroup="InsertHeUnitValFT" CommandName="Insert" UseSubmitBehavior="False" />
<br />
<asp:Button ID="btnCancelUnit" runat="Server" Text="Cancel" style="font-size: 8pt; width: 56px;" CausesValidation="false" ValidationGroup="InsertHeUnitValFT" CommandName="Cancel" UseSubmitBehavior="False" />
<br />
 <asp:Button ID="btnGetCorrespondingValues" Visible="true" runat="server" style="font-size: 6pt; width: 56px;" Text="Get Values" OnClick="btnGetCorrespondingValues_OnClick" />
</FooterTemplate>
                                             
</asp:TemplateField>

Open in new window

jazzcatoneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MogalManicCommented:
The ASP:Command field cannot be used in a template.  You can either do something like this:
        <Columns>
            <asp:CommandField ValidationGroup="InsertHeUnitValEDIT" CausesValidation="true"  DeleteText="Delete"  ShowDeleteButton="true" EditText="" ShowEditButton="true" />

Open in new window


or in a template field, manually create buttons:
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text=""></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete"></asp:LinkButton>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
            </asp:TemplateField>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.