View Single Post
  #5 (permalink)  
Old August 8th, 2012, 04:11 AM
cms9651 cms9651 is offline
Authorized User
Points: 121, Level: 2
Points: 121, Level: 2 Points: 121, Level: 2 Points: 121, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2012
Posts: 27
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
But where is the GridView? And where's the code that should update your database?

Imar
I'm sorry error to copy/paste... this is my page.aspx with GridView.
I don't need update values in the database, I need update only the view of GridView when I use the filtering in my web page.

E.g.: Use the filter for between date (DateStart and DataEnd) and in GridView I see only records between for this date.
Code:
<%@ Page Language="C#" AutoEventWireup="true" Culture="it-IT" CodeFile="COV2.aspx.cs"
    Inherits="COV2" %>

<!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 id="Head1" runat="server">
    <title></title>
</head>
<body onload="InitValidators()">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" EnableScriptGlobalization="true" EnableScriptLocalization="true"
        runat="server">
    </asp:ScriptManager>
    <div>
            <asp:TextBox ID="DateStart" runat="server" Width="70"></asp:TextBox>
            <img src="Images/calen.gif" id="Img1" alt="DateStart" onmouseover="this.style.cursor='pointer'"
                onmouseout="this.style.cursor='default'" />
            <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="DateStart"
                PopupButtonID="Img1" Format="dd/MM/yyyy" Animated="true">
            </ajaxToolkit:CalendarExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DateStart"
                ErrorMessage="Start" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="DateStart"
                ErrorMessage="Invalid date" Display="Dynamic" CssClass="redb" ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)\d\d$">
            </asp:RegularExpressionValidator>


            <asp:TextBox ID="DateEnd" runat="server" Width="70"></asp:TextBox>
            <img src="Images/calen.gif" id="Img2" alt="End" onmouseover="this.style.cursor='pointer'"
                onmouseout="this.style.cursor='default'" />
            <ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="DateEnd"
                PopupButtonID="Img2" Format="dd/MM/yyyy" Animated="true">
            </ajaxToolkit:CalendarExtender>
            <asp:ImageButton ID="Button1" ImageUrl="images/icon.gif" runat="server" OnClick="Button1_Click"
                OnClientClick="javascript:return InitValidators();return false;" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="DateEnd"
                ErrorMessage="End" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="DateEnd"
                ErrorMessage="Invalid date" Display="Dynamic" CssClass="redb" ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)\d\d$">
            </asp:RegularExpressionValidator>
            <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Invalid Date"
                ControlToValidate="DateEnd" ControlToCompare="DateStart" Type="Date"
                Operator="GreaterThanEqual" CssClass="redb" SetFocusOnError="false" Display="Dynamic">
            </asp:CompareValidator>



            <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
                Font-Size="10pt" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged">
                <asp:ListItem Value="%">---</asp:ListItem>
            </asp:DropDownList>

            <asp:DropDownList ID="DropDownList6" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
                Font-Size="10pt" OnSelectedIndexChanged="DropDownList6_SelectedIndexChanged">
                <asp:ListItem Value="%">---</asp:ListItem>
            </asp:DropDownList>

            <asp:TextBox ID="DateStart1" runat="server" Width="70"></asp:TextBox>
            <img src="Images/calen.gif" id="Img3" alt="Start" onmouseover="this.style.cursor='pointer'"
                onmouseout="this.style.cursor='default'" />
            <ajaxToolkit:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="DateStart1"
                PopupButtonID="Img3" Format="dd/MM/yyyy" Animated="true">
            </ajaxToolkit:CalendarExtender>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="DateStart1"
                ErrorMessage="Start" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="DateStart1"
                ErrorMessage="Invalid date" Display="Dynamic" CssClass="redb" ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)\d\d$">
            </asp:RegularExpressionValidator>


            <asp:TextBox ID="DateEnd1" runat="server" Width="70"></asp:TextBox>
            <img src="Images/calen.gif" id="Img4" alt="End" onmouseover="this.style.cursor='pointer'"
                onmouseout="this.style.cursor='default'" />
            <ajaxToolkit:CalendarExtender ID="CalendarExtender4" runat="server" TargetControlID="DateEnd1"
                PopupButtonID="Img4" Format="dd/MM/yyyy" Animated="true">
            </ajaxToolkit:CalendarExtender>
            <asp:ImageButton ID="Button2" ImageUrl="images/icon.gif" runat="server" OnClick="Button2_Click"
                OnClientClick="javascript:InitValidators();return false;" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="DateEnd1"
                ErrorMessage="End" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="DateEnd1"
                ErrorMessage="Invalid date" Display="Dynamic" CssClass="redb" ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/](19|20)\d\d$">
            </asp:RegularExpressionValidator>
            <asp:CompareValidator ID="CompareValidator2" runat="server" ErrorMessage="Invalid Date"
                ControlToValidate="DateEnd1" ControlToCompare="DateStart1" Type="Date"
                Operator="GreaterThanEqual" CssClass="redb" SetFocusOnError="false" Display="Dynamic">
            </asp:CompareValidator>

        <asp:Label ID="Label1" runat="server"></asp:Label>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            PageSize="25" ShowHeader="true" OnPageIndexChanging="GridView1_PageIndexChanging">
            <Columns>
                <asp:BoundField DataField="DateStart" HeaderText="DateStart" />
                <asp:BoundField DataField="DateEnd" HeaderText="Datend" />
                <asp:BoundField DataField="DateStart1" HeaderText="DateStart1" />
                <asp:BoundField DataField="DateEnd1" HeaderText="Datend1" />
                <asp:BoundField DataField="sID" HeaderText="sID" />
            </Columns>
        </asp:GridView>
        <asp:DataList ID="DataList1" runat="server" RepeatLayout="Table" RepeatColumns="3"
            CellPadding="2" CellSpacing="2">
            <ItemTemplate>
            </ItemTemplate>
        </asp:DataList>
    </div>
    <asp:ValidationSummary ID="ValidationSummary1" ShowMessageBox="true" runat="server"
        ShowSummary="false" />
    <script type="text/javascript" language="javascript">
        function InitValidators() {

            var DateStart = document.getElementById('<%=DateStart.ClientID%>');
            var DateEnd = document.getElementById('<%=DateEnd.ClientID%>')
            var DateStart1 = document.getElementById('<%=DateStart1.ClientID%>');
            var DateEnd1 = document.getElementById('<%=DateEnd1.ClientID%>')

            if (DateStart.value == '' || DateEnd.value == '') {
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator1.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator2.ClientID%>'), true);
            }
            else {
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator1.ClientID%>'), false);
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator2.ClientID%>'), false);

            }

            if (DateStart1.value == '' || DateEnd1.value == '') {
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator3.ClientID%>'), true);
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator4.ClientID%>'), true);
            }
            else {
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator3.ClientID%>'), false);
                ValidatorEnable(document.getElementById('<%= RequiredFieldValidator4.ClientID%>'), false);
            }
        }
    </script>
    </form>
</body>
</html>
Reply With Quote