Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

comprehensive gridview example

Posted on 2009-04-04
1
Medium Priority
?
240 Views
Last Modified: 2012-05-06
Do you know of an example of the Gridview so I can,
Add/Remove fields or
Edit them
Add record
Delete record
Format the fields

I have done most of it in my example, however, I do not know the best way to format or insert record
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditExample_formview.aspx.cs" Inherits="EditExample" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
 
    protected void Page_Load(object sender, EventArgs e)
    {
            AccessDataSource1.DataFile = "~/App_Data/AccountInfo.mdb";
            AccessDataSource1.SelectCommand="SELECT Scenario.* from Scenario";
            AccessDataSource1.UpdateCommand = "UPDATE Scenario SET BusinessStartYear = ?, ReportingStart = ?, ReportingEnd = ?, FilterString = ? WHERE ScenarioID = ?";
            AccessDataSource1.DeleteCommand="DELETE FROM Scenario WHERE ScenarioID = ?";
            AccessDataSource1.InsertCommand="INSERT xxx  = ?";
            AccessDataSource1.UpdateParameters.Add("BusinessStartYear", "DateTime");
            AccessDataSource1.UpdateParameters.Add("ReportingStart", "DateTime");
            AccessDataSource1.UpdateParameters.Add("ReportingEnd", "DateTime");
            AccessDataSource1.UpdateParameters.Add("FilterString", "String");
            AccessDataSource1.DeleteParameters.Add("ScenarioID", "Int32");
    }
</script>
1
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataKeyNames="ScenarioID" DataSourceID="AccessDataSource1" PageSize="16" AllowSorting="True" AutoGenerateColumns="true" >
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            </Columns>
        </asp:GridView>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server">
        </asp:AccessDataSource>
 
 
 
 
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
            DataSourceID="AccessDataSource1" Height="50px" Width="125px">
            <Fields>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            </Fields>
        </asp:DetailsView>
 
 
 
 
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:goodk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 1500 total points
ID: 24071322
get the sample code here

http://www.codeproject.com/KB/webforms/Editable_GridView.aspx

http://www.codeproject.com/KB/webforms/EditGridviewCells.aspx

just register yourself in the website and download the source code.

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Viewers will learn the different options available in the Backstage view in Excel 2013.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question