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

Stored Procedure Driven Data Grid

Rate me:
Please Sign up or sign in to vote.
4.08/5 (11 votes)
22 Mar 2010CPOL3 min read 27.2K   441   27  
Dynamically updates datagrid columns and formats without changing the code files
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Basic.aspx.cs" Inherits="Basic" %>

<!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>Basic Sample</title>
    <link href="~/grid.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
    .label { font-weight:bold;}
    .normal { background:pink; text-align:center; }
    </style>
</head>
<body style="font-family:Verdana, Tahoma; font-size:11px;">
    <form id="form1" runat="server">
    <div>
        <a href="Basic.aspx">Basic</a>&nbsp;|&nbsp;
        <a href="OpenDetailClientSide.aspx">Open Detail Client Side</a>&nbsp;|&nbsp;
        <a href="OpenDetailServerSide.aspx">Open Detail Server Side</a>
    </div>
    <hr />
    <div>
        <h2>Basic</h2>
    </div>
    <div>
        <center>
            <div style="margin: 5px 10px 2px 0px;">
                <table border="0" cellpadding="1" cellspacing="1">
                    <tr style="text-align: left;">
                        <td class="label">Search :</td>
                        <td>&nbsp;</td>
                        <td class="label">Starts On :</td>
                        <td>&nbsp;</td>
                        <td class="label">Ends On:</td>
                    </tr>
                    <tr>
                        <td>
                            <asp:TextBox ID="TextBox_SearchCriteria" Width="130px" runat="server" CssClass="normal"></asp:TextBox>
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <asp:TextBox ID="TextBox_StartsOn" Width="100px" runat="server" CssClass="normal"></asp:TextBox>
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <asp:TextBox ID="TextBox_EndsOn" Width="100px" runat="server" CssClass="normal"></asp:TextBox>
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <asp:Button ID="Button_Query" runat="server" Text="GO" 
                                onclick="Button_Query_Click" />
                        </td>
                    </tr>
                </table>
            </div>
            <asp:GridView ID="gvMain" runat="server" AutoGenerateColumns="true" Style="margin-top: 20px;">
            </asp:GridView>
            <br />
            <asp:Label ID="Label_Info" runat="server" style="color:Red;"></asp:Label>
        </center>
    </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
Engineer
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions