Sandeep Kumar

Sandeep Kumar

  • 1.1k
  • 683
  • 60.4k

How Show QR Code In Lot1,Lot2 etc,It Is Dynamic Column Coming From SP

Jan 4 2023 7:46 AM

I Want to Show QR Code In Place Of  LOT Column i.e Lot1,Lot2,Lot3 etc,Which is Coming from Stored Prosedure.

My Code Aspx Page----

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterIQMS.master" EnableEventValidation="false" AutoEventWireup="true" CodeFile="SamplePrepration.aspx.cs" Inherits="Reports_SamplePrepration" %>
<%@ Register Src="~/Web Controls/CustomPager.ascx" TagName="PagingControl" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
         <div class="row">
            <div class="col-sm-4">
                Work Order No
                        <asp:TextBox ID="txtWorkOrderNo" runat="server" OnTextChanged="txtWorkOrderNo_TextChanged" AutoPostBack="true"></asp:TextBox>
                <asp:HiddenField ID="HiddenField1" runat="server" />
                <cc1:AutoCompleteExtender ServiceMethod="SearchWO" MinimumPrefixLength="1" EnableCaching="false" CompletionSetCount="10"
                    TargetControlID="txtWorkOrderNo" ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false"
                    CompletionListCssClass="completionList" CompletionListItemCssClass="listItem" CompletionListHighlightedItemCssClass="itemHighlighted">
                </cc1:AutoCompleteExtender>
            </div>
            <div class="col-sm-1">
                &nbsp;&nbsp;
                        <asp:LinkButton ID="btnInspectionCodeTagging" runat="server" Width="150" class="btn btn-info btn-xs btn-block" OnClick="btnInspectionCodeTagging_Click"><i class="fa-floppy-o"></i>&nbsp;Job Code Tagging</asp:LinkButton>
            </div>
        </div>
    <asp:Panel ID="pnlContents" runat="server">
          <div style="overflow: scroll;" onscroll="OnScrollDiv(this)" id="DivMainContent">
                 <asp:GridView ID="grdSamplePrep" runat="server" CssClass="table-grid" OnRowDataBound="grdSamplePrep_RowDataBound" OnSelectedIndexChanged="grdSamplePrep_SelectedIndexChanged1">
            </asp:GridView>
    
                   </div>
    </asp:Panel>
        <div class="row">
            <div class="col-sm-8">
                <asp:HiddenField ID="hidPageNo" runat="server" Value="1" />
                <uc1:PagingControl ID="gvPager" Visible="false" FirstString="<< First"
                    LastString=" Last >>" NextString="Next >" PrevString="< Prev" TotalNumberPaging="10" OnPaging_Click="gvPager_Paging_Click"
                    runat="server" />
            </div>
        </div>
</asp:Content>

Cs Page

using QRCoder;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Reports_SamplePrepration : System.Web.UI.Page
{
    SqlConnection con;
    int PageNum = 1;
    String strConn = ConfigurationManager.ConnectionStrings["ConOrms"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
          //  ShowData(1);
        }
    }

    protected void grdSamplePrep_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

        }
    }
    protected void ShowData(int PageNum)
    {
        int TotalRecord = 0;
        DataTable dt = new DataTable();
        int WOID = Convert.ToInt32(ViewState["WoidForBindData"]);
        DataSet dsSmplPrep = new DataSet(); //WR_TRF.GetTRFReport(BranchID, FromDate, ToDate, Convert.ToInt16(SessionManager.Instance.RoleId),txtTRFno.Text.Trim());
        DataTable dtSmplPrep = new DataTable();
        try
        {
            using (SqlConnection con = new SqlConnection(strConn))
            {
                using (SqlCommand cmd = new SqlCommand("VVS_SAMPLE_PREPARARION", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@WOID", SqlDbType.Int).Value = WOID;
                    //cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = 10;
                    cmd.CommandTimeout = 999999;
                    SqlDataAdapter adp = new SqlDataAdapter(cmd);
                
                    adp.Fill(dtSmplPrep);
                }
            }
        }
        catch (Exception ex)
        {

        }


          ///  DataTable distinctParameter = new DataTable();
          //  DataView viewSampleLlst = new DataView(dtSmplPrep);
            if (dtSmplPrep.Rows.Count > 0)
            {
            //   distinctParameter = viewSampleLlst.ToTable(true, "TotalCount");
            //  TotalRecord = Convert.ToInt16(distinctParameter.Rows[0]["TotalCount"]);
            dtSmplPrep.Columns.Remove("WOID");
            dtSmplPrep.Columns.Remove("TestingParamId");
            grdSamplePrep.DataSource = dtSmplPrep;
                grdSamplePrep.DataBind();
                //gvPager.Visible = (dtSmplPrep.DefaultView.Count > 0);
                //gvPager.PageSize = 10;
                //gvPager.TotalRecord = TotalRecord;
                //gvPager.CurrentPage = PageNum;
                //hidPageNo.Value = PageNum.ToString();
                //gvPager.DataLoad();
                //ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + grdQrCodeResult.ClientID + "', 300, 750 , 41 ,true); </script>", false);
            }
            else
            {
                //gvPager.Visible = false;
                grdSamplePrep.DataSource = null;
                grdSamplePrep.DataBind();
            }
        }
    protected void gvPager_Paging_Click(object sender, CommandEventArgs e)
    {

    }

    #region AutoComplete Work order No
    [System.Web.Script.Services.ScriptMethod()]
    [System.Web.Services.WebMethod]
    public static List<string> SearchWO(string prefixText, int count)
    {
        List<string> customers = new List<string>();
        string Item = string.Empty;
        try
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConOrms"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "GetWoIdBySearchText";
                    cmd.Parameters.Add("@SearchText", SqlDbType.NVarChar).Value = prefixText;
                    cmd.Connection = con;
                    con.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            Item = AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(sdr["JobOrderNo"].ToString(), sdr["WOID"].ToString());
                            customers.Add(Item);
                        }
                    }
                    con.Close();
                }
            }
        }
        catch (Exception ex)
        {
        }
        return customers;
    }
    #endregion

    protected void txtWorkOrderNo_TextChanged(object sender, EventArgs e)
    {
        int Woid = 0;
        //string WONO= txtTextingWO.Text;
        //GetEditWorkOrder(GetWorkOrderID(WONO));
        if (txtWorkOrderNo.Text != string.Empty)
        {
            try
            {
                string[] FindValue = txtWorkOrderNo.Text.Trim().Split(';');
                if (FindValue.Length > 1)
                {
                    Woid = Convert.ToInt32(FindValue[1].ToString());
                    ViewState["WoidForBindData"] = Woid;
                }
                txtWorkOrderNo.Text = FindValue[0].ToString();
            }
            catch (Exception ex) { }

        }
    }

    protected void btnInspectionCodeTagging_Click(object sender, EventArgs e)
    {
        ShowData(1);
    }
    protected void grdSamplePrep_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
}

My Screen

 

 


Answers (2)