Click here to Skip to main content
Sign Up to vote bad
good
See more: C#ASP.NET
i have to put delete button in gridview without using templatefield.
 
i am in very big difficulty .please help me.
Posted 31 Dec '12 - 5:26


5 solutions

use a CommandField and set the ShowDelete property to true
 
<asp:commandfield ShowDeleteButton="true" />
  Permalink  
hey refer below link..
Hope it will helpful.
ASP.NET GridView delete confirmation using asp:CommandField[^]
 
Happy Coding,
Happy New Year.
Smile | :) Big Grin | :-D
  Permalink  
<asp:GridView ID="GridView1" runat="server" OnRowDeleted="GridView1_RowDeleted">
           <Columns>
 
               <asp:CommandField ShowDeleteButton="true" />
           </Columns>
       </asp:GridView>
 

Fire RowDeleted events
  Permalink  

bgcolor="#9999FF"><code><code><pre lang="HTML"><pre lang="HTML"></pre></pre>




<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" width="100%" xmlns:asp="#unknown">
ShowFooter="True" BackColor="#CCCCCC" BorderColor="#999999" BorderWidth="3px"
CellPadding="4" CellSpacing="2" DataKeyNames="code" Style="color: #FFC080" ForeColor="Black"
OnRowCommand="doDelete">


<selectedrowstyle backcolor="#6699FF" font-bold="True" forecolor="White" />

ForeColor="White" Height="10px" HorizontalAlign="Center" VerticalAlign="Middle"
Wrap="True" />
<headerstyle backcolor="Black" forecolor="White" cssclass="text" font-bold="True">
Wrap="True" />


<%--شماره--%>
<asp:templatefield headertext="کد تدریس">

<asp:literal id="lit" runat="server">


<asp:literal id="lit_number" runat="server" text="<%# eval("code") %>">



<%--شماره--%>
<%--نام--%>
<asp:templatefield headertext="کد تدریس">

<asp:textbox id="edit_name" runat="server" text="<%# Bind("tadrisName") %>" height="20px">
Width="88px">


<asp:textbox id="txt_name" runat="server" width="86px" height="20px">


<%#Eval("tadrisName")%>



<%--نام--%>

<%-- دكمه هاي انصراف وویرایش --%>
<asp:commandfield buttontype="Button" canceltext="انصراف" edittext="ویرایش" showeditbutton="True">
UpdateText="ویرایش" HeaderText="ویرایش">

BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />


<%-- حذف --%>
<asp:templatefield headertext="حذف" showheader="False" itemstyle-forecolor="#DEDFDE">

<asp:button id="btnRemove" runat="server" causesvalidation="False" commandname="Delete">
Text="delet" OnClientClick="return confirm('?آیا مایل به delet این پست هستید');" />


Font-Names="Tahoma" Font-Size="X-Small" ForeColor="Black" />


<asp:templatefield headertext="حذف انتخابي" itemstyle-forecolor="#DEDFDE">

<asp:button commandname="Delete1" text="حذف" id="btnRemove1" runat="server" borderstyle="Solid">
OnClientClick="return confirmDelete();" BorderWidth="1px" BackColor="#DEDFDE"
Font-Names="Tahoma" Font-Size="11px" CssClass="menu" />


<asp:checkbox id="ChkRemove" runat="server">


<headerstyle backcolor="Black" horizontalalign="Center" />

ForeColor="Red" />


<%--<asp:buttonfield buttontype="Button" commandname="btnselect" text="انتخاب" headertext="دکمه انتخاب " />--%>

</headerstyle>





  Permalink  
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="lnkDelete" CommandArgument='<%#Eval("ID-through you are delete record") %>'
                            CommandName="cmdDelete"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
 

 
This way you are used to delete button in grid view & fire rowCommand event in codebehind....
  Permalink  
Comments
prashant patil 4987 - 1 Jan '13 - 0:53
hey kapil.. he want to put delete button without using template field in grid view and your solution is with template Field. Read Question again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 263
1 Sergey Alexandrovich Kryukov 254
2 Maciej Los 161
3 Tadit Dash 110
4 Richard MacCutchan 95
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,917
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,125


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid