Link to home
Start Free TrialLog in
Avatar of goodk
goodkFlag for United States of America

asked on

comprehensive gridview example

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

ASKER CERTIFIED SOLUTION
Avatar of Kamaraj Subramanian
Kamaraj Subramanian
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial