Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 522013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:18:37+00:00 2026-05-13T08:18:37+00:00

We have a very simple page for displaying the records. Basically, it passes certain

  • 0

We have a very simple page for displaying the records.

Basically, it passes certain phoneno and if it’s found then displayed and there is a potential the same number that is why using repeater. This thing work nicely no problem BUT now the requirement change by introduicng the photo profile that needs to be displayed.

The way it works on this is basically once a return record it checkes the physical photo based on the PhoneID on the certain folder and if it’s exist then displayed such as “/images/profiles/1.jpg” and if it couldn’t find then use “/images/profiles/default.jpg”

I couldn’t make it work on how to render though.

ASPX:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="index.aspx.cs" Inherits="IndexPage" %>


<form id="form1" runat="server">
    <asp:label ID="lblErrMsg" runat="server" ></asp:label>


    <asp:Panel runat="server" ID="pnlMainNoRec" Visible="false">
    <table>
        <tr>
            <td>No record available.</td>
        </tr>
    </table>
    </asp:Panel>
    <asp:Panel runat="server" ID="pnlMainData" Visible="false">
        <asp:Repeater id="rptrMain" runat="server">
            <ItemTemplate>
                <table>
                    <tr valign="top">
                        <td>
                            <table>
                                <tr>
                                    <td><img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" /></td>
                                </tr>
                            </table>
                        </td>
                        <td>
                            <table>
                                <tr>
                                    <td><p>First Name:</p></td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "FirstName") %></td>
                                </tr>
                                <tr>
                                    <td>Last Name:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "LastName") %></td>
                                </tr>
                                <tr>
                                    <td>Status:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "Status") %></td>
                                </tr>

                                <tr>
                                    <td>Region:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "Region") %></td>
                                </tr>
                                <tr>
                                    <td>Address:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "Address") %></td>
                                </tr>
                                <tr>
                                    <td>Caller Type:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "CallerType") %></td>
                                </tr>
                                <tr>
                                    <td>Program:</td>
                                    <td><%# DataBinder.Eval(Container.DataItem, "ClientProgram")%></td>
                                </tr>
                                <tr>
                                    <td colspan="2">&nbsp;</td>
                                </tr>
                            </table>
                        </td>
                    </tr>

            </ItemTemplate>
        </asp:Repeater>

    </asp:Panel>

CS:

    using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.IO;

public partial class IndexPage : System.Web.UI.Page 
{
    protected string thisConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    protected string thisQuery = "SELECT * FROM AllPhoneList WHERE PhoneNumber=@PhoneNumber";
    protected string thisProfileLocation = "/images/profiles/";

    protected void Page_Load(object sender, EventArgs e)
    {
        string phoneNo = Request.QueryString["PhoneNumber"];

        GetDetail(phoneNo);
    }

    void GetDetail(string PhoneNumber)
    {
        try
        {
            using (SqlConnection conn = new SqlConnection(this.thisConnectionString))
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand(thisQuery, conn);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@PhoneNumber", SqlDbType.VarChar, 50);
                cmd.Parameters["@PhoneNumber"].Value = PhoneNumber;

                DataTable dt = new DataTable();

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(dt);
                int x = 0;
                if (dt.Rows.Count > 0)
                {
                    pnlMainData.Visible = true;

                    if (isFileExist(Int32.Parse(dt.Rows[x]["PhoneID"].ToString())))
                       ???

                    //lblMainFirstName.Text = dt.Rows[0]["FirstName"].ToString();
                    //lblMainLastName.Text = dt.Rows[0]["LastName"].ToString();
                    rptrMain.DataSource = dt;
                    rptrMain.DataBind();
                    x+=1;
                }
                else
                {
                    pnlMainNoRec.Visible = true;
                }
            }
        }
        catch (Exception err)
        {
            //lblErrMsg.Text = err.Message.ToString();
            pnlMainNoRec.Visible = true;
        }
    }

    public bool isFileExist(int phoneID)
    {
        string imageFolder;
        imageFolder = Server.MapPath(thisProfileLocation) + phoneID.ToString();
        if (File.Exists(imageFolder))
            return true;
        else
            return false;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:18:37+00:00Added an answer on May 13, 2026 at 8:18 am

    Change:

    <img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" />
    

    To:

    <img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" onerror="this.onerror=null;this.src='/images/profiles/default.jpg';" />
    

    When the image returns a 404, you will get the default image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.