Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to display 3 records from database if any data is null or blank i should get not data available error on that column.but all 3 column should be displayed in page.kindly help

<a href="https://ibb.co/48kF0Sz"></a>


What I have tried:

 try
  {
      MySqlConnection con = new MySqlConnection(constr);
      MySqlCommand cmd = new MySqlCommand();
      cmd.CommandText = "select md.M_Name from F_SubMembers_Details sm Inner
      Join FMember_Details md on md.M_Id = sm.Sub_Id where sm.M_Id = @S_Id
      limit 3 ";
      cmd.Parameters.AddWithValue("@S_Id", Session["name"].ToString());
      cmd.Connection = con;
      con.Open();
      Repeater_ClientSection.DataSource = cmd.ExecuteReader();
      Repeater_ClientSection.DataBind();
      foreach (RepeaterItem item in Repeater_ClientSection.Items)
      {

          Label lbl1 = (Label)item.FindControl("lblcname");
          if (lbl1.Text == "Null" || lbl1.Text == "")
          {
              lbl1.Text = "Item Not available";
          }

      }
      con.Close();
    }
  catch (Exception ex)
  {

  }
<asp:Repeater ID="Repeater_ClientSection" runat="server" Visible="true">
              <ItemTemplate>
 <div class="col-md-4 col-sm-6">
  <div class="serviceBox">
      class="service-icon fa fa-globe">
      <asp:Label ID="lblcname" runat="server" CssClass="title" Text='<%#
      Eval("M_Name") %> ' />

      <a href="#" class="read-more">
          <span>Read More</span>
          ^__i class="fa fa-angle-right">
      </a>
  </div>
  </div>
  </ItemTemplate>
  </asp:Repeater>
Posted
Updated 11-Jun-20 1:04am
v2

1 solution

C#
if (lbl1.Text == "Null" || lbl1.Text == "")

Are you sure that your database stores the word "Null" in its records?
 
Share this answer
 
Comments
Member 14059436 11-Jun-20 9:03am    
yes it does,but the problem is when there is a single record in db it gives me single record in repeater but my client needs other 2 columns should also display with error.
Richard MacCutchan 11-Jun-20 9:11am    
What other two columns are you referring to, and what is the problem with showing them?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900