Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I implemented vertical grid view with binding data.Here my requirement is read the grid view values based on that values i need to replace the images instead of values.
Here i can able to read the values but how can i pass images instead of values.

for example if the value is 0 i need to put one image,if the value is -ve i need to put the another image




protected void BindScoreData()
{
string DataId = Request.QueryString["q"];
DataTable Score = new DataTable();
SqlConnection conn = new SqlConnection(connString);
conn.Open();
SqlCommand cmd = new SqlCommand("PROC_DO_Score_Analysis", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DO_Ticker", SqlDbType.VarChar, 50).Value = DataId;
//SqlDataReader reader = cmd.ExecuteReader();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(Score);
Score.Columns[1].ColumnName = "CompanyName";
Score.Columns[2].ColumnName = "Sector";
Score.Columns[3].ColumnName= "SubSector";
Score.Columns[4].ColumnName = "FilingProbablility";
Score.Columns[5].ColumnName = "settlementProbablility";
GridView1.DataSource = Score;
//gridScore.DataBind();
GridView1.DataSource = ConvertColumnsAsRows(Score);
GridView1.DataBind();
//GridView1.HeaderRow.Visible = false;
GridView1.HeaderRow.Visible = false;
foreach (GridViewRow row in gridScore.Rows)
{
System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Row.FindControl("image1");
//String header = gridScore.Columns[i].HeaderText;
string h = row.Cells[0].Text;
//String cellText = row.Cells[i].Text;
string ss = row.Cells[1].Text;
if (ss == "0")
{
//img.ImageUrl = "resources/images/add.png";
//img.Visible = true;
}
else if (ss == "-ve")
{
}
else if (ss == "+ve")
{
}
else
{
}


}


how can i pass images highlighted above in that code.

any one please share any idea or related code to me.
Posted
Updated 11-Jun-15 22:13pm
v2

1 solution

Are you using some thing like this.
<asp:imagefield dataimageurlfield="<ImagePath>" headertext="Image" xmlns:asp="#unknown">

In your data model/entity class create new wrapper property of type string which will return image path to said field. (in the getter of this property write down your highlighted logic.

Hope this will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900