private void ShowData(string strSql) { string strConn = ConfigurationSettings.AppSettings["strConn"]; SqlConnection SqlConn = new SqlConnection(strConn); SqlDataAdapter SqlCmd = new SqlDataAdapter(strSql, SqlConn); DataSet SqlDS = new DataSet(); SqlCmd.Fill(SqlDS, "UserAnswer"); RowNum = DataGridLore.CurrentPageIndex * DataGridLore.PageSize + 1; string SortExpression = DataGridLore.Attributes["SortExpression"]; string SortDirection = DataGridLore.Attributes["SortDirection"]; SqlDS.Tables["UserAnswer"].DefaultView.Sort = SortExpression + " " + SortDirection; DataGridLore.DataSource = SqlDS.Tables["UserAnswer"].DefaultView; DataGridLore.DataBind(); for (int i = 0; i < DataGridLore.Items.Count; i++) { System.Web.UI.WebControls.Image imgRate = (System.Web.UI.WebControls.Image)DataGridLore.Items[i].FindControl("imgRate"); imgRate.Width = Convert.ToInt32(200 * Convert.ToDouble(DataGridLore.Items[i].Cells[5].Text.Trim()) / Convert.ToDouble(DataGridLore.Items[i].Cells[4].Text.Trim())); imgRate.ToolTip = Convert.ToString(System.Math.Round(Convert.ToDouble(DataGridLore.Items[i].Cells[5].Text.Trim()) / Convert.ToDouble(DataGridLore.Items[i].Cells[4].Text.Trim()) * 100, 1)) + "%"; } SqlConn.Dispose(); }
private void ShowData(string strSql) { string strConn = ConfigurationSettings.AppSettings["strConn"]; SqlConnection SqlConn = new SqlConnection(strConn); SqlDataAdapter SqlCmd = new SqlDataAdapter(strSql, SqlConn); DataSet SqlDS = new DataSet(); SqlCmd.Fill(SqlDS, "LoreInfo"); RowNum = DataGridLore.CurrentPageIndex * DataGridLore.PageSize + 1; LinNum = 0; string SortExpression = DataGridLore.Attributes["SortExpression"]; string SortDirection = DataGridLore.Attributes["SortDirection"]; SqlDS.Tables["LoreInfo"].DefaultView.Sort = SortExpression + " " + SortDirection; DataGridLore.DataSource = SqlDS.Tables["LoreInfo"].DefaultView; DataGridLore.DataBind(); for (int i = 0; i < DataGridLore.Items.Count; i++) { LinkButton LBDel = (LinkButton)DataGridLore.Items[i].FindControl("LinkButDel"); LBDel.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除选择知识点吗?')==false) return false;}"); } LabelRecord.Text = Convert.ToString(SqlDS.Tables["LoreInfo"].Rows.Count); LabelCountPage.Text = Convert.ToString(DataGridLore.PageCount); LabelCurrentPage.Text = Convert.ToString(DataGridLore.CurrentPageIndex + 1); SqlConn.Dispose(); }