i have many images in encoding form , i want to show image in in image control after decoding ,but it is not showing kindly help me for solving this
my code is given below
public void GetQuestions()
{
try
{
if (lblRollNo.Text != null)
{
string StudentCode = lblRollNo.Text;
StudentCode = StudentCode.PadLeft(5, '0');
ArrayList myArrayList = new ArrayList();
DataSet ds1 = BranchServerClass.GetStudentQuestionId(StudentCode);
foreach (DataRow dRow in ds1.Tables[0].Rows)
{
myArrayList.Add(dRow.Field<int>("examQ_Id"));
Session["Qno"] = myArrayList;
}
if (myArrayList.Count > 0)
{
byte[] imagedata = null;
int a = Convert.ToInt32(myArrayList[0].ToString());
Session["Qno"] = 0;
DataSet ds = BranchServerClass.GetStudentQuestion(StudentCode,a);
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
string dummyData = row["Q_Image"].ToString().Trim().Replace(" ", "+");
if (dummyData.Length % 4 > 0)
dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
imagedata = Convert.FromBase64String(dummyData);
string base64string1 = Convert.ToBase64String(imagedata, 0, imagedata.Length);
Image1.ImageUrl = "data:image/png;base64," + Decode(base64string1);
}
}
// else { Lblmessage.Text = "No question to display!"; }
}
}
else
{
//Lblmessage.Text = "Kindly insert Student Code";
}
}
catch (Exception ex)
{
//Lblmessage.Text = "No question to display";
}
}
public static string Decode(string data) {
return Encoding.UTF8.GetString(Convert.FromBase64String(data));
}