Click here to Skip to main content
15,892,059 members
Articles / Web Development / ASP.NET

Edit Individual GridView Cells in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.88/5 (84 votes)
14 Nov 2009CPOL5 min read 1.4M   26.3K   305  
Edit individual GridView cells without putting the entire row into edit mode.Examples using the SqlDataSource and ObjectDataSource controls are included.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Edit Individual GridView Cells</title>
    <link href="css/basic.css" rel="stylesheet" type="text/css" /> 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Editing individual GridView cells</h3>
        <h3>C#</h3>
        <ul>
            <li>
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/GridViewEditCell.aspx">Accessing data stored in session</asp:HyperLink>
            </li>
            <li>
                <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/GridViewEditCell2.aspx">Accessing data stored in session with UpdatePanel, Validator Controls and Paging &amp; Sorting</asp:HyperLink>
            </li>
            <li>
                <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/GridViewEditCellSql.aspx">Accessing data via the SqlDataSource control</asp:HyperLink> **
            </li>
            <li>
                <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="~/GridViewEditCellObject.aspx">Accessing data via the ObjectDataSource control</asp:HyperLink> **
            </li>
        </ul>
        <p></p>
        <ul>
            <li>
                <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/GridViewSpreadsheet.aspx">Gridview with spreadsheet styling accessing data stored in session</asp:HyperLink>
            </li>
            <li>
                <asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="~/GridViewSpreadsheetSql.aspx">Gridview with spreadsheet styling accessing via the SqlDataSource control</asp:HyperLink> **
            </li>
        </ul>
         
        <br />
        <h3>VB.NET</h3>
        <ul>
            <li>
                <asp:HyperLink ID="HyperLink7" runat="server" NavigateUrl="~/GridViewEditCellVB.aspx">Accessing data stored in session</asp:HyperLink>
            </li>
            <li>
                <asp:HyperLink ID="HyperLink8" runat="server" NavigateUrl="~/GridViewEditCell2VB.aspx">Accessing data stored in session with UpdatePanel, Validator Controls and Paging &amp; Sorting</asp:HyperLink>
            </li>
        </ul
        
        <br /><br />
        <p>
            <i>** These examples use MS SQL Server. The connection string in the
            <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;web.config must configured correctly for these examples to work.</i>
        </p>
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Chief Technology Officer
Ireland Ireland
I have been designing and developing business solutions for the aviation, financial services, healthcare and telecommunications industries since 1999. My experience covers a wide range of technologies and I have delivered a variety of web and mobile based solutions.

Comments and Discussions