0

I need to use a <hr> tag under the date based on a condition. however its within a listview template and am haiving issues either finding it or trying to dynamically add it.

below is the code that loads the first article and stores its date in a temp location, if the second article matches the temp date it meets condition 1 and a date is not created. otherwise it meets condition 2 and a date is given. when the date is given i want a <hr> in the client side to be visable. Any ideas on the best method. i cant find the control when i use the findControl('controlname') method. Thanks

protected void Page_Load(object sender, EventArgs e)
        {
            LatestContent(); 

        }

        protected void LatestContent()
        {
            DataTable table1 = new DataTable("content"); //create datatable
            table1.Columns.Add("Date", Type.GetType("System.String"));
            table1.Columns.Add("title", Type.GetType("System.String"));
            table1.Columns.Add("intro", Type.GetType("System.String"));  

            using (apiContentDataContext api_GetContent = new apiContentDataContext())
            {

                var result = from c in api_GetContent.getAllContent().ToList()
                             select c; 

                   int count = 0;
                   var totalEntries = result.Count();
                   string tempDate = null;  

                        foreach (var entry in result)
                        {
                                string tableName = "table" + count;
                                DateTime formattedDate = (Convert.ToDateTime(entry.contentDate));//get
                                                                                                   date.                            
                                string newdate = formattedDate.ToString("dd MMMM yyyy");                                 

                                string[,] arrMultiD = 
                                  {
                                   {newdate, entry.contentTitle.ToString(), entry.contentIntro.ToString()}                                  
                                   };

                                if (tempDate == entry.contentDate.ToString() && count > 0) //condition1
                                {
                                    for (int i = 0; i < arrMultiD.GetLength(0); i++) //no date
                                    {
                                        table1.Rows.Add();//create a new row

                                        table1.Rows[table1.Rows.Count - 1]["title"] = arrMultiD[i, 1];
                                        table1.Rows[table1.Rows.Count - 1]["intro"] = arrMultiD[i, 2];

                                    }

                                }
                                else
                                {

                                    for (int i = 0; i < arrMultiD.GetLength(0); i++) //condition 2
                                    {
                                        table1.Rows.Add();//create a new row
                                        table1.Rows[table1.Rows.Count - 1]["Date"] = arrMultiD[i, 0];  
                                        table1.Rows[table1.Rows.Count - 1]["title"] = arrMultiD[i, 1];
                                        table1.Rows[table1.Rows.Count - 1]["intro"] = arrMultiD[i, 2];

                                        //NEED TO ADD <HR> RULE HERE 

                                    }
                                }
                        count ++;
                        tempDate = entry.contentDate.ToString(); //get diary date of first entry


                        }

                    LVContentHome.DataSource = table1;
                        LVContentHome.DataBind();

---------------------------- Client ----------------------------------------------------

<asp:ListView ID="LVContentHome" runat="server" OnPagePropertiesChanging="listItems_PagePropertiesChanging" EnableModelValidation="false">
   <LayoutTemplate>                
      <asp:PlaceHolder ID="itemPlaceholder" runat="server" />                
    </LayoutTemplate>

    <ItemTemplate>
        <div class="ded" id="ded" runat="server">
           <asp:Panel id="myDiv" runat="server">
               <a><%# Eval("Date")%><hr runat="server" id="dateHR" class="hrDate"/> </a>
           </asp:Panel>                                                                    
       </div>

    //loads other data here

 </ItemTemplate> 
    </asp:ListView>
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by JorgeM
0

If your solution is solved, it is appreciated if you post information about how you solved the problem so that others that have a similar issue can benefit from this thread.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.