Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:26am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

<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 at 1-Jan-13 0:53am
   
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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

use a CommandField and set the ShowDelete property to true
 
<asp:commandfield ShowDeleteButton="true" />
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

<asp:GridView ID="GridView1" runat="server" OnRowDeleted="GridView1_RowDeleted">
           <Columns>
 
               <asp:CommandField ShowDeleteButton="true" />
           </Columns>
       </asp:GridView>
 

Fire RowDeleted events
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5


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  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 878
1 OriginalGriff 410
2 CPallini 275
3 George Jonsson 226
4 Richard Deeming 145
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,482
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100