我想要隐藏gridview列,但我仍然希望访问其值,因为销售是针对代码列值完成的。这是我的代码 我想隐藏第一列(代码)这里是我的gridview代码..它不应该在运行时显示
DataTable dt;
private void MakeDataTable()
{
dt.Columns.Add("Code");
dt.Columns.Add("DESC");
dt.Columns.Add("Size");
dt.Columns.Add("QTY");
dt.Columns.Add("Price");
}
private void AddToDataTable()
{
string cat;
string brnd;
string cat_brnd;
if (txtSKU.Text != "" & txtqnt.Text != "")
{
int quantity = 0;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString);
con.Open();
//cmd = new SqlCommand("SELECT tbl_Product.strProductName,s.strSize,clr.strColorName, tbl_ItemDetail.strSalePrice,tbl_ItemDetail.nActualQuant FROM tbl_ItemDetail INNER JOIN tbl_Product ON tbl_ItemDetail.np_id = tbl_Product.np_id inner join tbl_Size s on tbl_ItemDetail.ns_id=s.ns_id inner join tbl_Color clr on tbl_ItemDetail.nclr_id=clr.nclr_id where tbl_ItemDetail.bnSKU='" + txtSKU.Text + "' ", con);
cmd = new SqlCommand("select c.strCategoryName,id.bnSKU,id.strBrand,s.nSizeCode,id.nActualQuant,id.strSalePrice from tbl_ItemDetail id inner join tbl_Size s on id.ns_id=s.ns_id inner join tbl_Category c on id.nc_id=c.nc_id where id.bnSKU='" + txtSKU.Text + "' and id.bisDeleted='False'", con);
sdr = cmd.ExecuteReader();
cmd.Dispose();
while (sdr.Read())
{
DataRow dr = dt.NewRow();
quantity = Convert.ToInt32(sdr["nActualQuant"].ToString());
cat = sdr["strCategoryName"].ToString();
brnd = sdr["strBrand"].ToString();
cat_brnd = "" + cat + "-" + brnd;
if (quantity != 0)
{
dr["Code"] = sdr["bnSKU"].ToString();
dr["DESC"] = cat_brnd.ToString();
dr["Size"] = sdr["nSizeCode"].ToString();
dr["QTY"] = txtqnt.Text;
dr["Price"] = sdr["strSalePrice"].ToString();
dt.Rows.Add(dr);
}
else
{
lbl_msg.Text = "Not In stock";
}
}
cmd.Parameters.Clear();
sdr.Close();
con.Close();
}
else
{
lbl_msg.Text = "Please Select Product to add in purchae List";
}
}
private void BindGrid()
{
gvsale.DataSource = dt;
gvsale.DataBind();
gvsale.Columns[0].Visible = false;
}