private void CreateMenuWithXmlFile() { string path = @"E:\MyXmlFile.xml"; DataSet ds = new DataSet(); ds.ReadXml(path); Menu menu = new Menu(); menu.MenuItemClick += new MenuEventHandler(menu_MenuItemClick); for (int i = 0; i < ds.Tables.Count; i++) { MenuItem parentItem = new MenuItem((string)ds.Tables[i].TableName); menu.Items.Add(parentItem); for (int c = 0; c < ds.Tables[i].Columns.Count; c++) { MenuItem column = new MenuItem((string)ds.Tables[i].Columns[c].ColumnName); menu.Items.Add(column); for (int r = 0; r < ds.Tables[i].Rows.Count; r++) { MenuItem row = new MenuItem((string)ds.Tables[i].Rows[r][c].ToString()); parentItem.ChildItems.Add(row); } } } Panel1.Controls.Add(menu); Panel1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { GridView1.AllowPaging = false; //GridView1.DataSource = AccessDataSource1; GridView1.DataBind(); DateTime dt = DateTime.Now; string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString(); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("用户列表" + filename, System.Text.Encoding.UTF8) + ".xls"); //导出文件命名 Response.ContentEncoding = System.Text.Encoding.UTF8; //如果设置为"GB2312"则中文字符可能会乱码 Response.ContentType = "application/ms-excel"; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); Panel1.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.Flush(); Response.End(); }
private void exportpdf() { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=OrderInvoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); byte[] file; file = System.IO.File.ReadAllBytes(Server.MapPath("~/img/logotitle.jpg")); //ImagePath iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(file); jpg.ScaleToFit(150F, 150F); //Set width and height in float pdfDoc.Add(jpg); htmlparser.Parse(sr); //Label7.Text = "" + "<img src='img/logotitle.jpg' >"; pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void btnExcel_Click(object sender, EventArgs e) { string sql = GetWhereSql(); if (sql != "-1") { gvList.AllowPaging = false; List <TB_HouseGoods> gooQGooddList = this.houseSer.GetListArrayByStocking(sql, txtFrom.Text, txtTo.Text); gooQGooddList = gooQGooddList.FindAll(t => !(t.Nums == 0 && t.InNums == 0 && t.OutNums == 0 && t.GoodNum == 0)); this.gvList.DataSource = gooQGooddList; this.gvList.DataBind(); Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + xlfile); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //设置输出流为简体中文 this.EnableViewState = false; Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">"); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw); Panel1.RenderControl(hw); Response.Write(sw.ToString()); Response.End(); gvList.AllowPaging = true; Show(); } }
public void GoAnotherCamera() { if (flag == false) { camera1.SetActive(false); camera2.SetActive(true); flag = true; Debug.Log("Переключение на камеру 2"); btLeftRotate.SetActive(false); btRightRotate.SetActive(false); Panel1.SetActive(false); Panel2.SetActive(false); } else { camera2.SetActive(false); camera1.SetActive(true); flag = false; Debug.Log("Переключение на камеру 1"); btLeftRotate.SetActive(true); btRightRotate.SetActive(true); Panel1.SetActive(true); Panel2.SetActive(true); } }
protected override void Dispose(bool disposing) { Panel1.Dispose(); Panel2.Dispose(); base.Dispose(disposing); }
protected void btnsubmit_Click(object sender, EventArgs e) { string msc = "";//建立变量msc存储考生答案 for (int i = 1; i <= 10; i++) { RadioButtonList list = (RadioButtonList)Panel1.FindControl("cbk" + i.ToString()); if (list != null) { if (list.SelectedValue.ToString() != "") { msc += list.SelectedValue.ToString();//存储考生答案 } else { msc += "0";//如果没有选择则为0 } } } Session["Sans"] = msc;//考生答案 //更新考试结果数据表 string sql = "update tb_score set RigthAns='" + Ans + "',StudentAns='" + msc + "' where StudentID='" + lblStuNum.Text + "'"; BaseClass.OperateData(sql); Response.Redirect("result.aspx?BInt=" + tNUM.ToString()); }
protected void btnClosePostBack_Click(object sender, EventArgs e) { // 首先保存数据 // 然后关闭本窗体 PageContext.RegisterStartupScript(Panel1.GetClearDirtyReference() + ActiveWindow.GetHidePostBackReference()); }
protected void btnExport_Click(object sender, EventArgs e) { try { string strFileName = "AssessmentResults.xls"; Response.Clear(); Response.Buffer = true; //ADDED Response.AddHeader("content-disposition", "attachment;filename=" + strFileName); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } //***BEGIN GRID-ONLY CODE //System.IO.StringWriter stringWrite = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //grdAssess.RenderControl(htmlWrite); //Response.Write(stringWrite.ToString()); //Response.End(); //***END GRID-ONLY CODE } catch (Exception ex) { lblError.Text = ex.Message; } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.Charset = "windows-1254"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254"); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + insp.lesson_id + "_hafta_" + insp.week_id + "_" + insp.dayname + "_yoklaması.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Buffer = true; this.EnableViewState = false; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfdoc = new Document(PageSize.A4, 10f, 10f, 100f, 10f); HTMLWorker htmlparser = new HTMLWorker(pdfdoc); PdfWriter.GetInstance(pdfdoc, Response.OutputStream); pdfdoc.Open(); htmlparser.Parse(sr); pdfdoc.Close(); Response.Write(pdfdoc); Response.End(); }
private void exportpdf() { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GridViewData.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10, 10, 0, 0); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); //Response.ContentType = "application/pdf"; //Response.AddHeader("content-disposition", "attachment;filename=OrderInvoice.pdf"); //Response.Cache.SetCacheability(HttpCacheability.NoCache); //StringWriter sw = new StringWriter(); //HtmlTextWriter hw = new HtmlTextWriter(sw); //Panel1.RenderControl(hw); //StringReader sr = new StringReader(sw.ToString()); //Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); //HTMLWorker htmlparser = new HTMLWorker(pdfDoc); //PdfWriter.GetInstance(pdfDoc, Response.OutputStream); //pdfDoc.Open(); //htmlparser.Parse(sr); //pdfDoc.Close(); //Response.Write(pdfDoc); //Response.End(); }
protected void Button1_Click(object sender, EventArgs e) { int n = Convert.ToInt16(Session["n"]); string sans = ""; for (int i = 1; i <= n; i++) { RadioButtonList list = (RadioButtonList)Panel1.FindControl("cbk" + i.ToString()); if (list != null) { if (list.SelectedValue.ToString() != "") { sans += list.SelectedValue.ToString(); } else { sans += "0"; } } } Session["Sans"] = sans; //string sql = "Insert into tb_expnum set StuNo='" + Session["ID"] + "',StuName='" + Session["name"] + "',RightAns='" + Session["Sans"].ToString() + "', StudentAns='" + sans + "'"; string sql = "update tb_expnum set StudentAns='" + sans + "' where StuNo='" + Session ["ID"].ToString() + "'"; BaseClass.OperateData(sql); Response.Redirect("ExamResult.aspx?BInt=" + n.ToString()); }
/// <summary> /// Initialization and setup method /// </summary> /// <param name="name"></param> private void InitializeContainer(string name) { //Basic setup Name = name; IsSplitterFixed = true; SplitterDistance = 40; TabIndex = 0; //Location and Margin Location = new Point(0, 0); Margin = new Padding(2); Size = new Size(780, 749); //Orientation and other settings Dock = DockStyle.Fill; FixedPanel = FixedPanel.Panel1; Orientation = Orientation.Horizontal; //Suspended Layout Panel1.SuspendLayout(); Panel2.SuspendLayout(); SuspendLayout(); //Resume Layout Panel1.ResumeLayout(false); Panel2.ResumeLayout(false); Panel2.PerformLayout(); ResumeLayout(false); }
private void ExportGridToPDF() { string dt = System.DateTime.Now.ToString("MM/yyyy"); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=StudentFeesReport" + dt + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); iTextSharp.text.html.simpleparser.StyleSheet ST = new iTextSharp.text.html.simpleparser.StyleSheet(); ST.LoadTagStyle("body", "encoding", "Identity-H"); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); iTextSharp.text.html.simpleparser.HTMLWorker htmlparser = new iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc); htmlparser.Style = ST; PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); GridView1.AllowPaging = true; GridView1.DataBind(); }
protected void tab1_activate(object sender, DirectEventArgs e) { Panel1.Loader.SuspendScripting(); Panel1.Loader.Url = "Patient_Info.aspx?kind=TempPatient"; Panel1.Loader.DisableCaching = true; Panel1.LoadContent(); }
private bool Check() { bool check = false; int count = 0; for (int i = 0; i < 10; i++) { CheckBoxList ck = (CheckBoxList)Panel1.FindControl("cki" + i.ToString()); if (ck != null) { for (int j = 0; j < ck.Items.Count; j++) { if (ck.Items[j].Selected == true) { count++; } } } } if (count == 0) { ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('没有选择任何审批人!!');", true); return(check); } if (txt_zdrYJ.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('没有填写制单人意见!!');", true); return(check); } return(true); }
protected List <double> calculateAverage() { string conString = String.Format(@"Server=tcp:neredenyesek.database.windows.net,1433;Initial Catalog=Computerproject;Persist Security Info=False;User ID=serkanbekir;Password=serkan-94;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"); SqlConnection con = new SqlConnection(conString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; con.Open(); string firstCommand = "SELECT COUNT(distinct ad) FROM RESTORANLAR;"; cmd.CommandText = firstCommand; int restoranSayisi = (int)cmd.ExecuteScalar(); string secondCommand = "SELECT COUNT(distinct id) FROM UYELER;"; cmd.CommandText = secondCommand; int uyeSayisi = (int)cmd.ExecuteScalar(); double total = 0; List <double> averageList = new List <double>(); for (int i = 0; i < restoranSayisi; i++) { for (int j = i; j <= (uyeSayisi - 1) * restoranSayisi + i; j = j + restoranSayisi) { string id = "TextBox" + j.ToString(); TextBox tb = (TextBox)Panel1.FindControl(id); total = total + Convert.ToDouble(tb.Text); } total = total / uyeSayisi; averageList.Add(total); total = 0; } return(averageList); }
protected void ExportFile_ALL(object sender, EventArgs e) { GridView GridView_01 = (GridView)Panel1.FindControl("GridView_01"); string views = ""; foreach (GridViewRow row in GridView_01.Rows) { string viewname = row.Cells[11].Text; views += row.Cells[11].Text + " <br/>"; try { SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("exec spNDAR__ExportFile '" + viewname + "'", oConnData); sqlCmd.ExecuteNonQuery(); } catch (SqlException exc) { LogToPageError(exc.Message); } } //refresh the page LoadGrids(); }
protected void Button1_Click(object sender, EventArgs e) { BoletoBancario itau = PreparaBoleto(); MailMessage mail = PreparaMail(); if (RadioButton1.Checked) { mail.Subject += " - On-Line"; Panel1.Controls.Add(itau); System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htmlTW = new HtmlTextWriter(sw); Panel1.RenderControl(htmlTW); string html = sw.ToString(); // mail.Body = html; } else { mail.Subject += " - Off-Line"; mail.AlternateViews.Add(itau.HtmlBoletoParaEnvioEmail()); } MandaEmail(mail); Label1.Text = "Boleto simples enviado para o email: " + TextBox1.Text; }
protected void Button2_Click(object sender, EventArgs e) { int count = Convert.ToInt32(Session["clicks"]); SqlConnection con = new SqlConnection(sqlcon); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; for (int i = 0; i < count; i++) { TextBox tb = new TextBox(); string OptionID = "TextBoxU" + i; tb = (TextBox)Panel1.FindControl(OptionID); //TextBox tb = Panel1.FindControl("TextBoxU0") as TextBox; cmd.CommandText = "insert into Category(CategoryName)values('" + tb.Text + "')"; cmd.ExecuteNonQuery(); //TextBox txt; //foreach (Control c in Panel1.Controls) //{ // if (c.GetType() == typeof(TextBox)) // { // txt = (TextBox)c; // String str = txt.Text; // } //} } }
private void SetControlValue(DataTable dt)//设置控件值 { for (int i = 0; i < dt.Columns.Count; i++) { try { Control c = Panel1.FindControl("ext" + dt.Columns[i].ColumnName.Trim()); string type = c.GetType().Name.Trim(); switch (type) { case "ComboBox": ComboBox cbb = (ComboBox)c; cbb.SelectedItem.Value = dt.Rows[0][i].ToString().Trim(); break; case "TextArea": TextArea ta = (TextArea)c; ta.Text = dt.Rows[0][i].ToString().Trim(); break; } } catch { continue; } } }
public void MyDataBind() { CinemaLINQDataContext dt = new CinemaLINQDataContext(); List <SuatChieu> _dsSuatChieu = (from _sc in dt.SuatChieus where _sc.LichChieuPhim.NgayChieu.Date >= DateTime.Now.Date && _sc.TinhTrang == true orderby _sc.MaPhim ascending select _sc).ToList(); if (_dsSuatChieu.Count == 0) { return; } List <SuatChieu> _dsSuatChieuTheoPhim = new List <SuatChieu>(); int _currentPhim = -1; for (int i = 0; i < _dsSuatChieu.Count; i++) { if (_dsSuatChieu[i].MaPhim != _currentPhim) { _dsSuatChieuTheoPhim.Add(_dsSuatChieu[i]); _currentPhim = _dsSuatChieu[i].MaPhim; } } //DataList _temp = (DataList)Panel1.FindControl("dtl_DanhSachPhim"); ((DataList)Panel1.FindControl("dtl_DanhSachPhim")).DataSource = _dsSuatChieuTheoPhim; ((DataList)Panel1.FindControl("dtl_DanhSachPhim")).DataBind(); //dtl_DanhSachPhim.DataSource = _dsSuatChieuTheoPhim; //dtl_DanhSachPhim.DataBind(); }
private void SetDataFromControlToObject() { try { _TransferSavedList = new CustomList <TransferAndPromotionHistory>(); foreach (EntityList M in _entityList) { ASL.Hr.DAO.TransferAndPromotionHistory TPH = new TransferAndPromotionHistory(); TPH.EmpKey = Convert.ToInt64(hfEmpKey.Value); TransferAndPromotionHistory obj = _CurrentPosition.Find(f => f.EntityName == M.EntityName); TPH.PreHKEntryID = obj.PreHKEntryID; TPH.PreHKEntryName = obj.PreHKEntryName; TPH.EntityID = obj.EntityID; TPH.EntityName = obj.EntityName; DropDownList ddl = (DropDownList)Panel1.FindControl("ddlPost" + M.EntityName.ToString()); TPH.CurrentHKEntryID = ddl.SelectedValue.ToInt(); TPH.CurrentHKEntryName = ddl.SelectedItem.Text; TPH.EffectiveDate = txtEffectiveDate.Text.ToDateTime(); TPH.Type = ddlTransferType.SelectedValue.ToInt(); TPH.StatusType = "Transfer"; TPH.Remarks = txtRemarks.Text; TPH.NextReviewDate = txtNextReviewDate.Text.ToDateTime(); TPH.AddedBy = CurrentUserSession.UserCode; TPH.AddedDate = DateTime.Now; _TransferSavedList.Add(TPH); } } catch (Exception ex) { throw (ex); } }
private void LoadScriptsList(PatchProfile patch) { ComboBoxEx_Scripts.Items.Clear(); foreach (PatchScript script in patch.Scripts) { var item = new ComboItem(); if (!string.IsNullOrEmpty(script.Name)) { item.Text = script.Name; } else { item.Text = "Untitled"; } item.Tag = script; ComboBoxEx_Scripts.Items.Add(item); } if (ComboBoxEx_Scripts.Items.Count > 0) { ComboBoxEx_Scripts.SelectedIndex = 0; } Panel1.Refresh(); }
/// <summary> /// Initialization and setup method /// </summary> /// <param name="name"></param> private void InitializeSplitContainer(string name) { Name = name; Dock = DockStyle.Fill; FixedPanel = FixedPanel.Panel1; IsSplitterFixed = true; Location = new System.Drawing.Point(0, 0); Margin = new Padding(6); Orientation = Orientation.Horizontal; Size = new System.Drawing.Size(334, 411); SplitterDistance = 80; TabIndex = 24; Panel1.SuspendLayout(); Panel2.SuspendLayout(); SuspendLayout(); Panel1.ResumeLayout(false); Panel2.ResumeLayout(false); ResumeLayout(false); }
protected void btnImgSendMail_Click(object sender, ImageClickEventArgs e) { string path = Server.MapPath("~/exportedfiles/"); if (!Directory.Exists(path)) // CHECK IF THE FOLDER EXISTS. IF NOT, CREATE A NEW FOLDER. { Directory.CreateDirectory(path); } Session["filename"] = "DBSIndividualHeadReport.xls"; if (File.Exists(path + Session["filename"].ToString())) { File.Delete(path + Session["filename"].ToString()); // DELETE THE FILE BEFORE CREATING A NEW ONE. } using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter htw = new HtmlTextWriter(sw)) { StreamWriter writer = File.AppendText(path + "DBSIndividualHeadReport.xls"); //RenderAllGrid(sw, htw); Panel1.RenderControl(htw); writer.WriteLine(sw.ToString()); writer.Close(); } } Response.Redirect("SendMail.aspx"); }
protected void SaveAndClose() { // 首先保存数据 // 然后关闭本窗体 PageContext.RegisterStartupScript(Panel1.GetClearDirtyReference() + ActiveWindow.GetHidePostBackReference()); }
private void dynamicbutton_Click(Object sender, System.EventArgs e) { String strSQL = "select name from polling_in where name='" + this.CurrentUser.LogonID + "' and id_p='4' "; string connstr; //Response.Write(strSQL); connstr = (System.Web.Configuration.WebConfigurationManager.ConnectionStrings["EIPAConnectionString"].ConnectionString); //連線資料 SqlConnection conn = new SqlConnection(connstr); conn.Open(); SqlCommand cmd = new SqlCommand(strSQL, conn); //cmd.Connection.Open(); //打開連線 SqlDataReader dr = cmd.ExecuteReader(); //讀取內容 if (dr.Read()) { //Response.Write("不可投票"); Response.Write("<script language='JavaScript'>window.alert('投票已截止囉!');</script>"); GotoDefault(); } else { RadioButtonList tb = new RadioButtonList(); tb = (RadioButtonList)(Panel1.FindControl("dynamictextbox")); //Label1.Text = tb.Text; if (this.CurrentUser.LogonID == "") { Response.Write("<script language='JavaScript'>window.alert('請先登入!');</script>"); GotoDefault(); } else if (tb.Text == "") { Response.Write("<script language='JavaScript'>window.alert('請輸入選項!');</script>"); } else { //TextBox ta = new TextBox(); //ta = (TextBox)(Panel1.FindControl("dynamictextboxa")); ////string connstr; ////string con = ""; ////con = RadioButtonList1.SelectedItem.Value; ////Response.Write(con); ////connstr = ("Data Source=ANNLINV\\SQLEXPRESS;Initial Catalog=TTA3;Integrated Security=True; Integrated Security=SSPI;"); //SqlConnection connection = new SqlConnection(connstr); //SqlCommand DataCommand = new SqlCommand(); //DateTime d = DateTime.Now; ////Response.Write("Date = " +d.Date.ToString() + "<BR>"); //DataCommand.CommandText = "insert into polling_in(id_p,id_c,name,date,comment)values('2','" + tb.Text + "','" + this.CurrentUser.LogonID + "','" + d.ToString("yyyyMMdd") + "','" + ta.Text + "')"; ////Response.Write(ta.Text); ////Response.Write(DataCommand.CommandText); //DataCommand.Connection = connection; //connection.Open(); //DataCommand.ExecuteNonQuery(); //connection.Close(); Response.Write("<script language='JavaScript'>window.alert('投票已截止囉!');</script>"); GotoDefault(); } } }
protected void PrintGrid(GridView gv) { gv.AllowPaging = false; GetSearchResults(); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); string gridHTML = sw.ToString().Replace("\"", "'") .Replace(System.Environment.NewLine, ""); StringBuilder sb = new StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload = new function(){"); sb.Append("var printWin = window.open('', '', 'left=0"); sb.Append(",top=0,width=900,height=700,status=0');"); sb.Append("printWin.document.write(\""); sb.Append(gridHTML); sb.Append("\");"); sb.Append("printWin.document.close();"); sb.Append("printWin.focus();"); sb.Append("printWin.print();"); sb.Append("printWin.close();};"); sb.Append("</script>"); ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString()); gv.AllowPaging = true; gv.DataBind(); }
private void CreateTreeView() { DataSet ds = GetDataSet(); TreeNode node = null; Button button = new Button(); button.Click += new EventHandler(button_Click); button.Text = "Get Checked Noted"; tree = new TreeView(); foreach (DataRow dr in ds.Tables[0].Rows) { node = new TreeNode(); node.Text = (string)dr["CategoryName"]; node.ShowCheckBox = true; tree.Nodes.Add(node); } // Add to the Panel control Panel1.Controls.Add(tree); Panel1.Controls.Add(button); Panel1.DataBind(); }