public partial class Master : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
string strConnString = ConfigurationManager.ConnectionStrings["amitpandeyConnectionString"].ConnectionString;
string str;
SqlCommand com;
lb1.Text = "" + "WELLCOME:: " + "" + "" + Session["UserName"] + "";
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from Login where UserName='" + Session["UserName"] + "'";
com = new SqlCommand(str, con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
lbl_address.Text = ds.Tables[0].Rows[0]["UserId"].ToString();
lbl_sal.Text = ds.Tables[0].Rows[0]["Branch"].ToString();
lbl_phone.Text = ds.Tables[0].Rows[0]["Designation"].ToString();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
int[] nos = new int[Convert.ToInt32(txtNo.Text)];
for (int i = 0; i < nos.Length; i++)
nos[i] = i + 1;
GridView1.DataSource = nos;
GridView1.DataBind();
}
protected void btnInsert_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in GridView1.Rows)
{
TextBox txtBranch = (TextBox)gvRow.FindControl("txtBranch");
TextBox txtDate = (TextBox)gvRow.FindControl("txtDate");
TextBox txtSrNo = (TextBox)gvRow.FindControl("txtSrNo");
TextBox txtDocketNo = (TextBox)gvRow.FindControl("txtDocketNo");
TextBox txtPinCode = (TextBox)gvRow.FindControl("txtPinCode");
TextBox txtBasis = (TextBox)gvRow.FindControl("txtBasis");
TextBox txtTo = (TextBox)gvRow.FindControl("txtTo");
TextBox txtConsignorCode = (TextBox)gvRow.FindControl("txtConsignor");
TextBox txtConsignee = (TextBox)gvRow.FindControl("txtConsignee");
TextBox txtPKTS = (TextBox)gvRow.FindControl("txtPKTS");
TextBox txtActWt = (TextBox)gvRow.FindControl("txtActWt");
TextBox txtChargeWt = (TextBox)gvRow.FindControl("txtChargeWt");
TextBox txtTotalFreight = (TextBox)gvRow.FindControl("txtTotalFreight");
TextBox txtGoodsType = (TextBox)gvRow.FindControl("txtGoodsType");
TextBox txtCODamount = (TextBox)gvRow.FindControl("txtCODamount");
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["amitpandeyConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("insert into CreateDocket values (@Branch,@Date,@SrNo,@DocketNo,@PinCode,@Basis,@To,@ConsignorCode,@Consignee,@PKTS,@ActWt,@ChargeWt,@TotalFreight,@GoodsType,CODamount)", con);
cmd.Parameters.Clear();
cmd.Parameters.Add("Branch", txtBranch.Text);
cmd.Parameters.Add("Date", txtDate.Text);
cmd.Parameters.Add("SrNo", txtSrNo);
cmd.Parameters.Add("DocketNo", txtDocketNo.Text);
cmd.Parameters.Add("PinCode", txtPinCode.Text);
cmd.Parameters.Add("Basis", txtBasis.Text);
cmd.Parameters.Add("To", txtTo.Text);
cmd.Parameters.Add("ConsignorCode", txtConsignorCode.Text);
cmd.Parameters.Add("Consignee", txtConsignee.Text);
cmd.Parameters.Add("PKTS", txtPKTS.Text);
cmd.Parameters.Add("ActWt", txtActWt.Text);
cmd.Parameters.Add("ChargeWt", txtChargeWt.Text);
cmd.Parameters.Add("TotalFreight", txtTotalFreight.Text);
cmd.Parameters.Add("GoodsType", txtGoodsType.Text);
cmd.Parameters.Add("CODamount", txtCODamount.Text);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
What I want is lbl_sal.Text shows me which branch is logedin, I wanted that same text may come in all the textbox of branch when page loads