2016-08-06 2 views
0

나는 asp.net gridview 및 ajax 달력 익스텐더를 사용하고 있습니다. 예를 들어 사용자가 19/8/16과 같이 날짜를 선택하면 gridview 테이블에서만 19/8/16의 날짜가 표시됩니다. 그러나 문제는 내가 숨기고 gridview 표시 할 코드를 모른다. 누구든지 gridview를 숨기고 표시하는 방법을 알고 있습니까?Gridview 테이블을 숨기고 표시하는 방법은 무엇입니까?

출력 :

enter image description here

Asp.net 코드 :

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ViewAppliedLeaveByDate.aspx.cs" Inherits="BookReservation.ViewLeave.ViewAppliedLeaveByDate" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 

    <h3>View Leave Application By Start Date</h3> 
    <asp:Label ID="lblSearchStartDate" runat="server" CssClass="labelClass" Text="Search By Start Date:"></asp:Label> 
    <asp:TextBox ID="tbSearchStartDate" runat="server"></asp:TextBox> 
    <ajaxToolkit:CalendarExtender ID="tbSearchStartDate_CalendarExtender" runat="server" TargetControlID="tbSearchStartDate" /> 
    <br /> 
    <br /> 
    <asp:GridView ID="gvVALD" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDSSearchStartDate" > 
     <Columns> 
      <asp:BoundField DataField="StaffName" HeaderText="StaffName" SortExpression="StaffName" /> 
      <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" /> 
      <asp:BoundField DataField="StartDate" HeaderText="StartDate" SortExpression="StartDate" /> 
      <asp:BoundField DataField="Start Leave Period" HeaderText="Start Leave Period" SortExpression="Start Leave Period" /> 
      <asp:BoundField DataField="EndDate" HeaderText="EndDate" SortExpression="EndDate" /> 
      <asp:BoundField DataField="End Leave Period" HeaderText="End Leave Period" SortExpression="End Leave Period" /> 
      <asp:BoundField DataField="NumDays" HeaderText="NumDays" SortExpression="NumDays" /> 
     </Columns> 

    </asp:GridView> 
    <br /> 
    <asp:SqlDataSource ID="SqlDSSearchStartDate" runat="server" ConnectionString="<%$ ConnectionStrings:LeaveManagementCS %>" SelectCommand="SELECT Staff.StaffName, LeaveType.Type, LeaveApplications.StartDate, LeavePeriod.Description AS [Start Leave Period], LeaveApplications.EndDate, LeavePeriod.Description AS [End Leave Period], LeaveApplications.NumDays FROM LeaveApplications INNER JOIN LeavePeriod ON LeaveApplications.StartLeavePeriodId = LeavePeriod.LeavePeriodId AND LeaveApplications.EndLeavePeriodId = LeavePeriod.LeavePeriodId INNER JOIN LeaveType ON LeaveApplications.LeaveTypeId = LeaveType.Id INNER JOIN Staff ON LeaveApplications.StaffId = Staff.StaffId"></asp:SqlDataSource> 
</asp:Content> 

Asp.net.cs 코드 :

public partial class ViewAppliedLeaveByDate : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 

     } 
    } 
+0

하고 당신은있는 gridview를 보충 할 필요가 'tbSearchStartDate' 텍스트에 이벤트 – Webruster

+0

가 숨기고 싶은 조건을 변경 했습니까? –

답변

0

이 텍스트 상자 "tbSearchStartDate"에서의 TextChanged 이벤트를 만들 autopostback 속성을 true로 설정하고 선택한 공급 장치로 다시 그리드를 바인딩하십시오. 쿼리에 날짜

0

단순히 \ 숨기기를 보여 GridView 컨트롤의 Visible 속성을 설정 그것은 :

당신이 당신의 질문에 언급 된 날짜에 대한 데이터베이스를 조회 할 필요가
gvVALD.Visible = false; 
관련 문제