Wednesday, February 24, 2010

Image Control

private string IMAGEurl(out bool b)
{
string saveLocation = ""; b = false;
string imageurl = "/images/thumbnail/UnknownSuper.gif";
try
{

string imageName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string extention = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("."));

saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/user");

imageName = txtUsername.Text.ToString() + extention;

saveLocation = saveLocation + "/" + imageName;
// jerry 01-07-2009
Bitmap photo = objvalid.ResizeImage(File1.PostedFile.InputStream, 300, 300);// width height
photo.Save(saveLocation);
//
// File1.PostedFile.SaveAs(saveLocation);

saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/thumbnail");
saveLocation = saveLocation + "/" + imageName;
Bitmap photoFile = objvalid.ResizeImage(File1.PostedFile.InputStream, 64, 64);// width height
photoFile.Save(saveLocation);
if (photoFile.Height > photoFile.Width)
b = true;
imageurl = "/images/thumbnail/" + imageName;
}
catch
{ }
return imageurl;
}

showing using:<img border=0 src=" + thumbImg + " />

Gridveiw:Get all rows in one click

METHOD 1
===========================================
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{


try
{
Label5.Visible = true;
if (e.CommandName == "SET")
{
int IsFake = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{

int userid = int.Parse(GridView1.Rows[i].Cells[0].Text.ToString());
CheckBox chbTemp = GridView1.Rows[i].FindControl("chkBxSelect") as CheckBox;
if (chbTemp.Checked)
{
// Response.Write(GridView1.Rows[i].Cells[0].Text + "<BR>");
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}
}
catch { }
}

================================================================
METHOD 2
=================================================================
protected void btnSubmit_Click(object sender, EventArgs e)
{

foreach (GridViewRow row in GridView1.Rows) //GridView1.PageSize * GridView1.PageCount
{
int IsFake = 0;
//Label lfilName = (Label)row.FindControl("lblfilename");
int userid = int.Parse(row.Cells[0].Text.ToString());

CheckBox chbTemp = (CheckBox)row.FindControl("chkBxSelect");
if (chbTemp.Checked)
{

IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}