2016-08-06 23 views
0

私はasp.net gridviewとajaxカレンダーエクステンダーを使用しています。たとえば、ユーザが19/8/16のように日付を選択すると、gridviewテーブルでのみ19/8/16の日付が表示されます。しかし、問題は、私はどのコードを非表示にしてグリッドビューで表示するのか分かりません。誰でもグリッドビューの表示と非表示を知っていますか?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; 
関連する問題