ASP.NET - How to hide repeater? - Asked By saranya on 08-Jan-13 02:49 AM

Hi frndz!

iam doing project in asp.net 4.0. in my project iam using 2 grid to bind.Iam using repeater to bind

1.binddata_course()
2.binddata_lesson()

iam using dropdownlist.

1.course
2.lesson

when iam select course the selected value is 1,when iam select lesson the selected value is 2.

private void ddldetails_SelectedIndexChanged(object sender, EventArgs e)
      {
        if (ddldetails.SelectedValue == "1")
        {
          binddata_course();
        }

        else
        {
          binddata_lesson();
        }
      }



so in rptcertificate_ItemDataBound()

in repeater in aspx page iam design common

 <ItemTemplate>
       <tr>  
                       
             <td  class="tbldHdrNew" align="left" runat="server" id="tdusername" >
                <asp:Label ID="lbluser" runat="server" CssClass="repeater_label" Text='<%# Eval("UserName") %>'></asp:Label>               
              </td>
             <td  class="tbldHdrNew" align="left" runat="server" id="tdcoursename" >
                <asp:Label ID="lblcourse" runat="server" CssClass="repeater_label" Text='<%# Eval("CourseName") %>'></asp:Label>
                </td>
               
                <td  class="tbldHdrNew" align="left" runat="server" id="tdlessonname" >
                <asp:Label ID="lbllesson" runat="server" CssClass="repeater_label" Text='<%# Eval("LessonName") %>'></asp:Label>
             
              </td>  
              <td  align="left" class="tbldHdrNew">
                <asp:Label ID="lblLessonID" runat="server" Visible="false" Text='<%# Eval("LessonID") %>'></asp:Label>                
                <asp:Button CommandName="View" ID="btnview" runat="server" ToolTip="View Certificate"  CssClass="View"/>
              </td>
               </tr>
       </ItemTemplate>


when i select course in dropdown

it showing error in <td  class="tbldHdrNew" align="left" runat="server" id="tdlessonname" >
                <asp:Label ID="lbllesson" runat="server" CssClass="repeater_label" Text='<%# Eval("LessonName") %>'></asp:Label>
             
              </td> 


bcoz lessonname not in binddata_course so its showing error. so how to hide? urgent tell me frndz!
Vikas Sharma replied to saranya on 08-Jan-13 11:50 AM
Hello Friend,
              You have to make logic in the Item data bound of repeater control where firstly you have to find the label named 'lbllesson' the make a if condition where you will specilfy that if you find  "LessonName" then it will print lesson name otherwise it will leave and one more thing, remove Text='<%# Eval("LessonName") %>' from :-

<asp:Label ID="lbllesson" runat="server" CssClass="repeater_label" Text='<%# Eval("LessonName") %>'></asp:Label>

because you are printing it in runtime.
saranya replied to Vikas Sharma on 10-Jan-13 12:04 AM
ya k Thank u