protected void ggvqpdetail_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToUpper().ToString() == "PRINTREC") { try { // Set the printer to a printer in the dropdown box when the selection changes. PrintDocument printDoc = new PrintDocument(); string a = TextBox1.Text + TextBox2.Text + TextBox3.Text; DataTable dt = new DataTable(); IDataReader dr = ExamManagement.SP.Eval_QP_PrintSelect(a).GetReader(); dt.Load(dr); dr.Close(); dr.Dispose(); if (ddlprint.SelectedIndex != -1 && dt.Rows.Count > 0) { // The dropdown box's Text property returns the selected item's text, which is the printer name. printDoc.PrinterSettings.PrinterName = ddlprint.Text; ProcessStartInfo printJob = new ProcessStartInfo(); printJob.FileName = dt.Rows[0]["Filename"].ToString(); printJob.UseShellExecute = true; printJob.Verb = "printto"; printJob.CreateNoWindow = true; printJob.WindowStyle = ProcessWindowStyle.Hidden; printJob.Arguments = ddlprint.Text;//Getting Which Printer Process.Start(printJob); if(dr.Read()) { } } } catch(Exception ex) { Lblmsg.Visible = true; Lblmsg.Text = ex.Message; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)