Hi
I have a RadAsyncUpload to upload the image. Using another button named "UpLoad" generate the postback to upload the image. Save the image in sql Server database in binary format. Retrieve the binary data from the database and set it to the datavalue property of the RadBinary image control. The radbinary image displays the image in it's original size. I have set the width and height of the radbinary image as 200px but the the image is displayed in its original size.
If i will generate a postback again then the image is set in 200px height and width. Please give the solution for this problem.
void b1_Click(object sender, EventArgs e)
{
foreach (Telerik.Web.UI.UploadedFile file in uploader.UploadedFiles)
{
byte[] bytes = new byte[file.ContentLength];
string fname = file.FileName.ToString();
int length = bytes.Length;
file.InputStream.Read(bytes, 0, file.ContentLength);
SqlConnection dbconn = new SqlConnection(strconn);
try
{
string Query = "INSERT INTO RadBinaryImageDemo (ImageData,ImageName) VALUES " + " (@imgdata,@imgname)";
SqlCommand cmd = new SqlCommand(Query, dbconn);
SqlParameter[] param = new SqlParameter[2];
cmd.Parameters.AddWithValue("@imgdata",bytes);
cmd.Parameters.AddWithValue("@imgname", file.FileName);
dbconn.Open();
cmd.ExecuteNonQuery();
DataTable d1 = new DataTable();
string Query1 = "select ImageData from RadBinaryImageDemo where ImageName='" + fname + "'";
SqlDataAdapter sqldadap = new SqlDataAdapter(Query1, dbconn);
sqldadap.Fill(d1);
byte[] imgdata = ((byte[])d1.Rows[0]["ImageData"]);
binaryimage1.DataValue = imgdata;
}
finally
{
dbconn.Close();
}
}
}