我尝试从结果SqlDataSource绑定标签。但是我得到了这个错误
无法对System.String和System.Int32执行'='操作
<asp:SqlDataSource ID="SqlDataSource1" FilterExpression="DeviceID='{0}'"
runat="server" ConnectionString="<%$ ConnectionStrings:DBConn %>"
SelectCommand="SELECT devcocom_admin.SensorDataPackage.a_TankLevel1,
devcocom_admin.SensorDataPackage.a_TankLevel2,devcocom_admin.DeviceID bla bla
bla Where bla bla ">
<FilterParameters>
<asp:ControlParameter Name="DeviceID" ControlID="lblDeviceIDText"
PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
private void GetData()
{
DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
DataRowView drv =dv[0];
lblTank1.Text = drv["a_TankLevel1"].ToString();
lblTank2.Text = drv["a_TankLevel2"].ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
lblDeviceIDText.Text = this.m_Dealer.DeviceID.ToString();
// e.g lblDeviceIDText.Text=12345 can display on page
GetData();
}
我在此行收到错误
DataView dv =(DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
无法对System.String和System.Int32执行'='操作