I have a repeater that it has image inside itself. I want to show different image base on ranking for example if ranking is 1 I show an image and if it is 2 I show the other etc.and i have 5 kind of image and 5 grade too.
Ranking is a column in dataset. But my function does not work correctly and I can’t get correct result. It only shows first pic. What solution do you suggest for this operation??
thank a lot .
This is my code
public string getimg()
{
SqlConnection con = new SqlConnection("data source=.;database=site;integrated security=true;");
string sSQL = "Select username ,weight,point , Rank() over(order by point desc) as 'ranking' from karbar order by point desc";
SqlCommand cmd = new SqlCommand(sSQL, con);
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapt.Fill(ds);
foreach (DataRow myRow in ds.Tables[0].Rows)
{
if (Convert.ToInt32(myRow["ranking"]) == 1)
{ return "price/con1.png"; }
else return "price/con2.png";
}
}
and its html
<div class="innerTitle">
<img style="width:55px;height:55px" alt="" src="<%# getimg() %>" /> </div>
<div class="innerContent" style=" width: 391px; direction:rtl ">
Hello you can try with this answer
1 Modify your function
2 Add this selection code
3 in your call you must have your index Row printed in your page, in order to select
4 Get you index