Click here to Skip to main content
14,733,553 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=""></a>

What I have tried:

      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;
      Repeater_ClientSection.DataSource = cmd.ExecuteReader();
      foreach (RepeaterItem item in Repeater_ClientSection.Items)

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

  catch (Exception ex)

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

      <a href="#" class="read-more">
          <span>Read More</span>
Updated 11-Jun-20 2:04am

1 solution

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

Are you sure that your database stores the word "Null" in its records?
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