Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 30th, 2007, 11:44 PM
Registered User
 
Join Date: Jul 2007
Location: Kolkata, West Bengal, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dhurjati_sen Send a message via Yahoo to dhurjati_sen
Default Grid View in ASP.NET 2.0 Using C#

I have a grid view where i am a template field to delete a row. i want to capture the datakey value for the row.

How do i do this. Following the code:

<asp:GridView ID="gvAllEmployees" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
            BorderWidth="1px" CellPadding="4" DataKeyNames="UserID" DataSourceID="sdsAllEmployees"
            ForeColor="Black" GridLines="Vertical" HorizontalAlign="Center" Width="100%"
            PageIndex="10" PagerSettings-Mode="Numeric" EmptyDataText="There are no employee records to show."
            EmptyDataRowStyle-CssClass="labeltext" EmptyDataRowStyle-HorizontalAlign="center"
            EmptyDataRowStyle-VerticalAlign="middle" CssClass="gridview">
            <Columns>
                <asp:HyperLinkField DataNavigateUrlFields="UserID" DataNavigateUrlFormatString="~/EmployeeDetails.aspx?UserName={0}"
                    DataTextField="UserID" HeaderText="User ID" SortExpression="UserID" />
                <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                <asp:BoundField DataField="MiddleName" HeaderText="Middle Name" SortExpression="MiddleName" />
                <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                <asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
                <asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
                <asp:BoundField DataField="UserName" HeaderText="User Name" SortExpression="UserName" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="imgbtDelete" runat="server" ImageUrl="~/Images/Delete.gif" ToolTip="Delete Employee"
                            CausesValidation="false" CommandName="Delete" OnClientClick="return confirm('Pressing OK will delete this employee record. Do you wish to continue?')" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" HorizontalAlign="center" />
            <FooterStyle BackColor="#CCCC99" />
            <RowStyle BackColor="#F7F7DE" HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="White" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <PagerStyle HorizontalAlign="Center" CssClass="pages" />
        </asp:GridView>
    </ContentTemplate>
</asp:UpdatePanel>
<asp:SqlDataSource ID="sdsAllEmployees" runat="server" ConnectionString="<%$ ConnectionStrings:EmployeeTimeTrackerDBConnectionS tring %>"
    SelectCommand="GetAllEmployee" SelectCommandType="StoredProcedure" DeleteCommand="DeleteEmployee"
    DeleteCommandType="storedProcedure" DataSourceMode="DataSet"></asp:SqlDataSource>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Grid View Paging in VB.Net Prakash001 Visual Studio 2005 0 January 30th, 2008 07:44 AM
Help Grid View Drop Down List, view all jskinner123 ASP.NET 2.0 Basics 0 November 25th, 2007 06:25 PM
Refreshing a grid in asp.net 2.0 cpanson ASP.NET 2.0 Professional 3 March 5th, 2006 12:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.