c# - Getting values from database in an item databound -
i looking solution following scenario using asp.net & sql server.
i have repeater control ,i need display image within repeater control , based on range of values stored in database table.
database table : level1 min max 1 100 100 2 50 99 3 1 49
i used itemdatabound event repeater control. & hard coded min , max values . values database. 1 thing write stored procedure , call within item data bound event, concerned effect performance.
i know if there way min , max values database without effecting performance?
protected void rptmonitorsummary_onitemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { int x = convert.toint32(databinder.eval(e.item.dataitem, "x")); int y = convert.toint32(databinder.eval(e.item.dataitem, "y")); float percentage = (((float)x / (float)y)) * 100; if (percentage == 0) { ((image)e.item.findcontrol("btnperformanceimage")).imageurl = "../images/level1.png"; } else if (percentage > 49 && percentage < 100 ) { ((image)e.item.findcontrol("btnperformanceimage")).imageurl = "../images/level2.png"; } else if (percentage > 1 && percentage < 49) { ((image)e.item.findcontrol("btnperformanceimage")).imageurl = "../images/level3.png"; } }
i binding repeater in code :
rptsummary.datasource = getsummaryinfo(begintime.tostring(), endtime.tostring()); rptsummary.databind();
the getsummaryinfo method calls stored procedure performs calculation returns summary info x , y
Comments
Post a Comment