Ejemplo n.º 1
0
 public static void OutExcel(Page myPage, SmartGridView gv, string name, string codetype)
 {
     if (codetype == "")
     {
         codetype = "GB2312";
     }
     HttpResponse response = myPage.Response;
     string str = "attachment;filename=" + HttpContext.Current.Server.UrlEncode(name) + ".xls";
     gv.Visible = true;
     response.Clear();
     response.Buffer = true;
     response.Charset = codetype;
     response.AppendHeader("Content-Disposition", str);
     response.ContentEncoding = Encoding.GetEncoding(codetype);
     response.ContentType = "application/ms-excel";
     gv.EnableViewState = false;
     StringWriter writer = new StringWriter();
     HtmlTextWriter writer2 = new HtmlTextWriter(writer);
     gv.RenderControl(writer2);
     response.Write(writer.ToString());
     response.End();
 }
Ejemplo n.º 2
0
 public static void setGViewColumns(DataSet ds, SmartGridView gvResult)
 {
     if (gvResult.Columns.Count == 0)
     {
         BoundField field = null;
         for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
         {
             field = new BoundField {
                 DataField = ds.Tables[0].Columns[i].ColumnName,
                 HeaderText = ds.Tables[0].Columns[i].ColumnName,
                 SortExpression = ds.Tables[0].Columns[i].ColumnName
             };
             field.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
             if (IsEnglishStr(ds.Tables[0].Columns[i].ColumnName))
             {
                 field.Visible = false;
             }
             gvResult.Columns.Add(field);
         }
         ButtonField field2 = new ButtonField {
             CommandName = "two",
             Visible = false
         };
         gvResult.Columns.Add(field2);
         field2 = new ButtonField {
             CommandName = "Select",
             Visible = false
         };
         gvResult.Columns.Add(field2);
     }
     if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count == 0))
     {
         ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
     }
 }
Ejemplo n.º 3
0
 public static void GetSelectTJ(SmartGridView gvResult, ref DataSet DataSetClo, ref DataSet DataSetTable, ArrayList NotDisplayColumn)
 {
     DataSetClo = new DataSet();
     DataSetTable = new DataSet();
     DataSetClo.Tables.Add();
     DataSetTable.Tables.Add();
     foreach (DataControlField field in gvResult.Columns)
     {
         TemplateField field3;
         string name = field.GetType().Name;
         if (name != null)
         {
             if (!(name == "BoundField"))
             {
                 if (name == "TemplateField")
                 {
                     goto Label_0164;
                 }
             }
             else
             {
                 BoundField field2 = (BoundField) field;
                 if (((field2.Visible && (field2.HeaderText != "序号")) && ((NotDisplayColumn == null) || !GetSelectTJ_pd(gvResult, field, NotDisplayColumn, field2.DataField))) && (DataSetClo.Tables[0].Columns.IndexOf(field2.DataField) == -1))
                 {
                     if (DataSetClo.Tables[0].Columns.IndexOf(field2.DataField) == -1)
                     {
                         DataSetClo.Tables[0].Columns.Add(field2.DataField);
                     }
                     if (DataSetTable.Tables[0].Columns.IndexOf(field2.HeaderText) == -1)
                     {
                         DataSetTable.Tables[0].Columns.Add(field2.HeaderText);
                     }
                 }
             }
         }
         continue;
     Label_0164:
         field3 = (TemplateField) field;
         if (((field3.Visible && (field3.HeaderText != "序号")) && (field3.SortExpression != "")) && ((NotDisplayColumn == null) || !GetSelectTJ_pd(gvResult, field, NotDisplayColumn, field3.SortExpression)))
         {
             if (DataSetClo.Tables[0].Columns.IndexOf(field3.SortExpression) == -1)
             {
                 DataSetClo.Tables[0].Columns.Add(field3.SortExpression);
             }
             if (DataSetTable.Tables[0].Columns.IndexOf(field3.HeaderText) == -1)
             {
                 DataSetTable.Tables[0].Columns.Add(field3.HeaderText);
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// gridview强制不换行
 /// </summary>
 /// <param name="objView"></param>
 public static void setGridKeepAll(SmartGridView objView)
 {
     objView.HeaderRow.Style.Add("word-break", "keep-all");
     foreach (GridViewRow row in objView.Rows)
     {
         foreach (TableCell cell in row.Cells)
         {
             cell.Wrap = false;
             cell.Style.Add("word-break", "keep-all");
         }
     }
 }
Ejemplo n.º 5
0
 private static bool GetSelectTJ_pd(SmartGridView gvResult, DataControlField column, ArrayList NotDisplayColumn, string BindDataName)
 {
     foreach (object obj2 in NotDisplayColumn)
     {
         if (BindDataName == obj2.ToString())
         {
             column.Visible = false;
             return true;
         }
     }
     return false;
 }