我是通过代码隐藏的gridview的数据绑定:
protected void PumpGridBind()
{
string name = Request.QueryString[1].ToString();
string query = "select q1.ID , q1.Scenario, q1.Type, q1.StationName ,q1.minH,
q1.maxH ,q1.Station_Id, q1.Min_OL, q1.Max_OL, q2.Daily_Abstraction as Action
from
(select SD.id,SD.Scenario,PR.Type,PR.StationName,max(if(PARAM = 'minH', Value, '
-999.00'))
as 'minH',max(if(PARAM = 'maxH', Value, ' -999.00'))
as 'maxH',psd.Station_Id,psd.Min_OL,psd.Max_OL from sgwebdb.param_reference as PR
Inner
join
sgwebdb.scenario_data as SD ON PR.Param_Id = SD.Param_Id INNER JOIN
sgwebdb.qualicision_detail as Q ON SD.SCENARIO = Q.Alternative INNER JOIN
sgwebdb.pump_station_detail as psd ON psd.Station_Id = PR.Station_Id where PR.Type
= 'Pump' and Q.Alternative = '" + name + "' GROUP BY PR.Id) q1 JOIN (SELECT
t1.Daily_Abstraction ,t1.Station_id FROM sgwebdb.pump_station_data t1 INNER JOIN
(SELECT
Station_id, MAX(lastupdate) as lastupdate FROM sgwebdb.pump_station_data GROUP BY
Station_id ) t2 ON t1.Station_id = t2.Station_id AND t1.lastupdate = t2.lastupdate)
q2 on
q1.Station_Id=q2.Station_Id";
this.GridView2.DataSource = PSI.DataAccess.Database.DatabaseManager.GetConnection
().GetData(query);
GridView2.DataBind();
}
这里gridview的列minH以字符串形式出现。 我们可以在使用gridview绑定之前将字符串转换为Double吗?
答案 0 :(得分:0)
你可以使用
string query = "select q1.ID , q1.Scenario, q1.Type, q1.StationName ,**CAST(q1.minH as DECIMAL(9,2)) q1.minH**