Hi SUJAYS,
Please refer below code.
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
Code
C#
PKDA.cs
public DataTable BindPackage(int PK)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection conPack = new SqlConnection(constr);
conPack.Open();
SqlCommand cmdPack = new SqlCommand("SP_PKGALLINFO", conPack);
{
try
{
cmdPack.CommandType = CommandType.StoredProcedure;
cmdPack.Parameters.AddWithValue("@PK", PK);
SqlDataAdapter da = new SqlDataAdapter(cmdPack);
DataTable dt = new DataTable();
da.Fill(dt);
conPack.Close();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
}
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
BindPack();
}
private void BindPack()
{
try
{
PKDA objBal = new PKDA();
gvPackage.DataSource = objBal.BindPackage(1);
gvPackage.DataBind();
gvPackage.Columns[0].Visible = false;
gvPackage.Visible = true;
}
catch (Exception ex)
{
this.LogError(ex);
}
}