数据转换问题?难啊?请教!
public partial class User_Default2 : System.Web.UI.Page{ public string sql, sqls, sqlm, AdInfo_ID, url, aids, info; public int uaid; public double sumprice; protected System.Data.SqlClient.SqlCommand cmd; protected System.Data.SqlClient.SqlConnection conn; public DataSet ds; Utils uitls = new Utils(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DateTime date = DateTime.Now; String YMD1 = date.ToShortDateString().ToString(); String YMD2 = date.AddDays(1.1).ToShortDateString().ToString(); CalendarInput1.Text = YMD1.ToString(); CalendarInput2.Text = YMD2.ToString(); } if (Session["user"] == null) Response.Redirect("Login_user.aspx"); else power_sql(); } private void power_sql() { conn = uitls.conn(); CheckAdInfoSort(); FirstBindData(); } public void CheckAdInfoSort() { string rq1, rq2, caller,callnum; rq1 = CalendarInput1.Text.Trim(); rq2 = CalendarInput2.Text.Trim(); caller = Session["user"].ToString(); callnum = uitls.FiledValue("select top 1 usernum from userinfo_cb where bak_phoneno='" + caller + "'"); if (rq1 == "" && rq2 == "") { sql = "select count(*) from SysFeeDate_CB where usernum='"+callnum+"' or callernum='"+caller+"' and fee>0"; sqls = "select starttime,usernum,calleenum,holdmin,fee*0.01 as fee,calltype from SysFeeDate_CB where usernum='" + callnum + "' or callernum='" + caller + "' and fee>0 order by id desc"; } else { //sql = "select count(*) from SysFeeDate_CB where (usernum='" + callnum + "' or callernum='" + caller + "') and starttime>'" + rq1 + "' and starttime<'" + rq2 + " 23:59:59' and fee>0"; //sqls = "select starttime,usernum,calleenum,holdmin,fee*0.01 as fee from SysFeeDate_CB where (usernum='" + callnum + "' or callernum='" + caller + "') and starttime>'" + rq1 + "' and starttime<'" + rq2 + " 23:59:59' and fee>0"; sql = "select count(*) from SysFeeDate_CB where starttime>'" + rq1 + "' and starttime<'" + rq2 + " 23:59:59' and fee>0 and ((calltype in (1,2) and callernum='"+caller+"') or (calleenum='"+caller+"' and calltype=0))"; sqls = "select starttime,usernum,calleenum,holdmin,fee*0.01 as fee,calltype from SysFeeDate_CB where starttime>'" + rq1 + "' and starttime<'" + rq2 + " 23:59:59' and fee>0 and ((calltype in (1,2) and callernum='"+caller+"') or (calleenum='"+caller+"' and calltype=0))"; } } public void FirstBindData() { try { cmd = new SqlCommand(sql, conn); conn.Open(); pager.RecordCount = (int)cmd.ExecuteScalar(); if (pager.RecordCount == 0) Label1.Text = "所选时间内无记录"; else { conn.Close(); Label1.Text = ""; } } catch (Exception ex) { //Response.Write(sqls); Label1.Text = ex.Message; } BindData(); } public void BindData() { try { cmd = new SqlCommand(sqls, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); ds = new DataSet(); adapter.Fill(ds, pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize, "SLC_call"); adapter.Fill(ds, "result"); for (int i = 0; i < ds.Tables["SLC_call"].Rows.Count; i++) //循环表记录,进行更改字段内容 { string memo; memo = ds.Tables["SLC_call"].Rows[i]["calltype"].ToString(); if (memo =="2") ds.Tables["SLC_call"].Rows[i]["calltype"] = "是"; else ds.Tables["SLC_call"].Rows[i]["calltype"] = "否"; } DataGrid1.DataSource = ds.Tables["SlC_call"]; DataGrid1.DataBind(); } catch (Exception ex) { //Response.Write("<script>alert('错误的操作,请查看您的选择日期或与网站管理人员联系.')</script>"); Response.Write(ex.Message); } AddCustomText(); } }