Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:GridView ID="grdViewManualAttendance" runat="server" AutoGenerateColumns="False"
                                        BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
                                         EnableViewState="False" Font-Size="Small" Width="680px"
                                      
                                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                                        <Columns>
                                        <asp:TemplateField>
                                            <HeaderTemplate>
                                                <asp:Button ID="btnDelete" runat="server" Text="Delete"
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkDelete" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                            <asp:BoundField DataField="AttendanceID" HeaderText="AttendanceID" ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="Date" DataFormatString="{0:dd/mm/yyyy}" HeaderText="Date"
                                                ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="Time" DataFormatString="{0:hh:mm:ss}" HeaderText="Time" ItemStyle-Width="20px" />
                                            <asp:BoundField DataField="GraceTime" HeaderText="GraceTime"
                                                ItemStyle-Width="20px" />
                                                <asp:BoundField DataField="IsActive" HeaderText="IsActive"
                                                ItemStyle-Width="20px" />

                                                <asp:BoundField DataField="Remarks" HeaderText="Remarks"
                                                ItemStyle-Width="20px" />


                                                <asp:BoundField DataField="IsAutomaticPull" HeaderText="IsAutomaticPull"
                                                ItemStyle-Width="20px" />
                                                <asp:BoundField DataField="IsLate" HeaderText="IsLate"
                                                ItemStyle-Width="20px" />
                                                 <asp:HyperLinkField DataNavigateUrlFields="AttendanceID" DataNavigateUrlFormatString="ManualAttendance.aspx?AttendanceID={0}&amp;Flag=y"
                                                HeaderText="Edit" Text="Edit">
                                                <ItemStyle Width="20px" VerticalAlign="Middle" HorizontalAlign="Center" />
                                            </asp:HyperLinkField>

                                        </Columns>
                                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                                        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                                        <AlternatingRowStyle BackColor="#DCDCDC" />
                                    </asp:GridView>

This is my grid view...Here i cant find delete button event. And Row command event not work .How can i solve it .pls help me
Posted

Try this

C#
protected void Button2_Click1(object sender, EventArgs e)
    {
        GridViewRow header = GridView1.HeaderRow;
        Button ddlCol = header.FindControl("Button2") as Button;

        if (ddlCol != null)
        {
            // Retrieve value 
            Response.Write(ddlCol.Text);
        }
    }


Thanks
 
Share this answer
 
if u fill this grid at the time of page load make sure that u have written code in
if(!IsPostBack)
{
// here write code to fill grid
}
block...

to take the Delete button event... open ur aspx page in design view... select ur grid view.. u will find > arrow at the upper right corner.. click on it... then select edit template field option...then select ur template field from the list.. then u can find the button.. select that button and double click on it.... u will get the Click event of delete button
 
Share this answer
 
Add
C#
CommandName="Delete" 
to your asp:Button.
 
Share this answer
 
Do following change in your code..

C#
<asp:gridview id="grdViewManualAttendance" runat="server" autogeneratecolumns="False" backcolor="White" bordercolor="#999999" borderstyle="None" borderwidth="1px" enableviewstate="False" font-size="Small" width="680px" xmlns:asp="#unknown">OnRowCommand="Griddealers_RowCommand"

<asp:templatefield><HeaderTemplate><asp:button id="btnDelete" runat="server" text="Delete" onclick="Clickevent()">
</asp:button></asp:templatefield></asp:gridview>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900