AnkitPal says:
SqlDataReader rdr = cmd.ExecuteReader();
using
(rdr)
{
if
(rdr.HasRows)
{
rdr.Read();
txtCID.Text = rdr[
"CID"
].ToString();
imgADphoto.ImageUrl = rdr[
"CustPhoto"
].ToString();
}
else
{
}
}
cnn.Close();
Change the above line of code like below.
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
imgADphoto.ImageUrl = rdr["CustPhoto"].ToString();
imgADsign.ImageUrl = rdr["CustSign"].ToString();
}
cnn.Close();
Also i have created sample please refer the below code.
HTML
<div>
<asp:TextBox runat="server" ID="txtCID" OnTextChanged="txtCID_OnTextChanged" AutoPostBack="true" />
<br />
<div class="textmid2" style="float: left;">
Adviser Photo :<br />
<div class="view_img1">
<asp:ImageMap ID="imgADphoto" runat="server" Width="140px" Height="150px">
</asp:ImageMap>
</div>
</div>
<div class="textright" style="float: inherit;">
Adviser Sign :<br />
<div class="view_sign1">
<asp:ImageMap ID="imgADsign" runat="server" Width="140px" Height="150px">
</asp:ImageMap>
</div>
</div>
</div>
Code
protected void txtCID_OnTextChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("CID"), new DataColumn("CustPhoto"), new DataColumn("CustSign") });
dt.Rows.Add("16020001", "~/Images/Chrysanthemum.jpg", "~/Images/Desert.jpg");
dt.Rows.Add("16020002", "~/Images/Hydrangeas.jpg", "~/Images/Jellyfish.jpg");
dt.Rows.Add("16020003", "~/Images/Koala.jpg", "~/Images/Lighthouse.jpg");
dt.Rows.Add("16020004", "~/Images/Penguins.jpg", "~/Images/Tulips.jpg");
string cId = txtCID.Text.Trim();
DataRow rdr = (from row in dt.AsEnumerable()
where row.Field<string>("CID") == cId
select row).FirstOrDefault();
imgADphoto.ImageUrl = rdr["CustPhoto"].ToString();
imgADsign.ImageUrl = rdr["CustSign"].ToString();
}
Screenshot