文本框为空时如何返回所有值

时间:2018-08-21 11:06:34

标签: c# asp.net gridview webforms textbox

我有一个文本框[DepartureRunwayTextBox]与一栏[DepartureRunway]绑定。如果文本框为空,我想在GridView中检索所有值。我将ConvertEmptyStringToNull设置为false,并在true和false上尝试了CancelSelectOnNullParameter,它无法按我想要的方式工作。请让我知道如何解决此问题。

Aspx

<asp:Label ID="DepartureRunwayLabel" runat="server" Text="Departure Runway" Font-Size="Medium"></asp:Label>&nbsp;
<asp:TextBox ID="DepartureRunwayTextBox" runat="server" Font-Size="Medium"></asp:TextBox>

<asp:SqlDataSource ID="DepartureRunwaySqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Departure Runway] AS Departure_Runway FROM [Movement]" CancelSelectOnNullParameter="True"></asp:SqlDataSource>


    ...

<asp:Panel ID="GridViewPanel" runat="server">
            <asp:GridView ID="GridView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="AircraftID" DataSourceID="GridViewDataSource" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" OnSelectedIndexChanged="GridView_SelectedIndexChanged" EnableSortingAndPagingCallbacks="True" ShowFooter="True" Visible="False">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
    ...

Aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ATOMS2._0
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Search_Click(object sender, EventArgs e)
        {
            GridView.Visible = true;
        }

        protected void GridView_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}

0 个答案:

没有答案