0

I am binding string array to the Repeater Control,

string[] strPageSize = new string[25];

repPageSize.DataSource = strPageSize;
repPageSize.DataBind();

.aspx Page Code

<asp:Repeater ID="repPageSize" runat="server">
                <ItemTemplate>                    
                    <a href="#" id="lnkPageIndex" rev="pageIndex" runat="server" onserverclick="lnkPageIndex_Click"><%#(string) (Container.DataItem)%></a>
                </ItemTemplate>
           </asp:Repeater>

but this string array may contains the null or empty string,and i don't want to bind them to my control.How i can avoid this.

thanks in advance.

gofor.net
  • 4,218
  • 10
  • 43
  • 65

1 Answers1

3

You can use LINQ.Extensions namespace like this:

string[] strPageSize = new string[25];

repPageSize.DataSource = strPageSize.Where(s => !string.IsNullOrEmpty(s));
repPageSize.DataBind();
seteh
  • 389
  • 4
  • 13