这是我的GridView和LinqDataSource
<div id="container">
<asp:GridView ID="dgvClients" runat="server" OnSelectedIndexChanged="dgvClients_SelectedIndexChanged"
CssClass="table table-hover table-striped table-condensed" GridLines="None"
ShowHeaderWhenEmpty="True"
AutoGenerateColumns="False" AllowPaging="True" DataSourceID="LinqDataSourceClient">
<Columns>
<asp:BoundField DataField="accno" HeaderText="Acc No" ReadOnly="True" SortExpression="accno"></asp:BoundField>
<asp:BoundField DataField="clientname" HeaderText="Client name" ReadOnly="True" SortExpression="clientname"></asp:BoundField>
<asp:TemplateField HeaderText="Branch" SortExpression="t_branch.branch" >
<ItemTemplate>
<%# Eval("t_branch.branch")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="active" HeaderText="Active" ReadOnly="True" SortExpression="active"></asp:BoundField>
<asp:BoundField DataField="lastupdated" HeaderText="Last Updated" ReadOnly="True" SortExpression="lastupdated"></asp:BoundField>
</Columns>
<Columns>
</Columns>
<PagerStyle CssClass="pagination" />
</asp:GridView>
<asp:LinqDataSource runat="server" EntityTypeName="" ID="LinqDataSourceClient" ContextTypeName="mcollector.mcollectorDataContext" OrderBy="accno, clientname, branchid" Select="new (accno, clientname, branchid, active, lastupdated, t_branch)" TableName="t_Clients" Where="accno == @accno">
<WhereParameters>
<asp:ControlParameter ControlID="TextBoxSearch" PropertyName="Text" DefaultValue="" Name="accno" Type="String"></asp:ControlParameter>
</WhereParameters>
</asp:LinqDataSource>
</div>
我有一个文本框,当它为空时我想显示表中的所有记录。 我怎么能这样做?
答案 0 :(得分:1)
您可以在LinqDataSource.Selecting Event
中编写逻辑代码