How to control a repeater with a non-fixed column number

I use a repeater to bind all the data in the table.

And the fields of My table are Name, Option1, Option2 ... Option12. All 13 columns. Option column values ​​are dynamic. for a while it contains two values ​​for Option1 and 2, and some numbers can vary from 1 to 12.

Now I want to show only those columns of parameters that contain some value.

Like this: -

Name
Option1
Option2
Option8

Name
Option10
Option12
Option4
Otion3

Name
Option5
Option7

Name
Option3
Option2
Option5
Option12
Option4

Options are not fixed. how can I control this with a repeater. In this way, he can show a meaning like this. Please suggest me the correct way to solve this problem.

Thanks at Advance.

First edit

<%# !Equals(DataBinder.Eval(Container.DataItem, "Option1")%>
....
<%# !Equals(DataBinder.Eval(Container.DataItem, "Option12")%>

, 12 . , 1 - 5, , 6 12 .

+5
3

,

                                                                                                                                                                                                          

  <ItemTemplate>
        <tr style="background-color:FFECD8">
           <td valign="top">
              <%# DataBinder.Eval(Container.DataItem, "ID") %>
           </td>
           <td valign="top">
              <%# DataBinder.Eval(Container.DataItem,"Name") %>
           </td>
           <td>
             <asp:Repeater Runat="server" ID="ordersRepeater" EnableViewState="false"
                DataSource='<%# DataBinder.Eval(Container.DataItem, "Orders") %>'>
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "OrderID") %> - <%# DataBinder.Eval(Container.DataItem, "OrderName") %> - <%# DataBinder.Eval(Container.DataItem, "OrderCost")%>
                    <br />
                </ItemTemplate>
            </asp:Repeater>
           </td>
        </tr>
  </ItemTemplate>


  <FooterTemplate>
     </Table>
  </FooterTemplate>

:

System; System.Collections.Generic; System.Data; System.Data.SqlClient; System.Configuration; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls;

System.Text; System.Xml; System.Xml.Schema;

{   private int id;   public int ID   {       get {return this.id; }       set {this.id = ; }   }

private string name;
public string Name
{
    get { return this.name; }
    set { this.name = value; }
}

public List orders;
public List Orders
{
    get { return this.orders; }
    set { this.orders = value; }
}

}

{   private int orderID;   public int OrderID   {       get { this.orderID; }       set {this.orderID = ; }   }   private string orderName;   public string OrderName   {       get {return this.orderName; }       set {this.orderName = ; }   }   private decimal orderCost;   public decimal OrderCost   {       get { this.orderCost; }       set {this.orderCost = ; }   } }

_Default: System.Web.UI.Page {   protected void Page_Load ( , EventArgs e)   {        orders1 = List();        order1 = Order();       order1.OrderID = 1;       order1.OrderName = "Pepsi";       order1.OrderCost = 12.5M;       orders1.Add(1);

    Order order2 = new Order();
    order2.OrderID = 2;
    order2.OrderName = "7up";
    order2.OrderCost = 12M;
    orders1.Add(order2);

    List orders2 = new List();
    Order order3 = new Order();
    order3.OrderID = 4;
    order3.OrderName = "Food";
    order3.OrderCost = 12.5M;
    orders2.Add(order3);

    List customers = new List();
    Customer c1 = new Customer();
    c1.ID = 1;
    c1.Name = "Bilal";
    c1.Orders = orders1;
    customers.Add(c1);

    Customer c2 = new Customer();
    c2.ID = 2;
    c2.Name = "potterosa";
    c2.Orders = orders2;
    customers.Add(c2);


    this.Repeater1.DataSource = customers;
    this.Repeater1.DataBind();
}

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{

}

}

http://forums.asp.net/t/1118175.aspx/1

+3

You should use the Repeater ItemDataBound Event to check an empty column, if you find that this column has values, then you can display them, if the column has no values, then you can set their visible property to false.
A very good example for you. You must look at it.

0
source

All Articles