सत्र स्थिति क्यों काम नहीं कर रही है?


जब मैं व्यवस्थापक पृष्ठ पर जोड़ें बटन पर क्लिक करता हूं, तो मैं चाहता हूं कि यह उपयोगकर्ता पृष्ठ पर प्रत्येक रक्त समूह की कुल इकाई संख्या प्रदर्शित करे। इसलिए यहां, मैंने इसे प्रदर्शित करने के लिए सत्र स्थिति का उपयोग किया, लेकिन फिर भी, यह काम नहीं कर रहा है और कोई त्रुटि नहीं दिखा रहा है। मैंने वेब कॉन्फ़िगरेशन में भी परिवर्तन किए हैं.

मैंने क्या प्रयास किया है:

This Button is from Gridview (Admin page)

protected void Button3_Click(object sender, EventArgs e)
{
    con.Open();

    //    string query1 = "SELECT SUM(Unit) AS TotalUnit,Blood_Group FROM TableDF GROUP BY Blood_Group ";

    SqlCommand com2 = new SqlCommand("SELECT SUM(Unit) AS TotalUnit1,Blood_Group FROM TableDF GROUP BY Blood_Group ", con);



    SqlDataReader reader = com2.ExecuteReader();

    while (reader.Read())
    {
        string BloodGroup1 = reader["Blood_Group"].ToString();
        int TotalUnit1 = Convert.ToInt32(reader["TotalUnit1"]);

        Session[BloodGroup1 + "TotalUnit1"] = TotalUnit1;

    }
    reader.Close();
    con.Close();
}
This is User Page 

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Label3.Visible = true;
                Label4.Visible = true;
                Label5.Visible = true;
                Label6.Visible = true;
                Label7.Visible = true;
                Label8.Visible = true;
                Label9.Visible = true;
                Label10.Visible = true;
            }

            if (Session["A+_TotalUnit"] != null)
            {
                Label3.Text = " " + Session["A+_TotalUnit"].ToString();
            }
            if (Session["A-_TotalUnit"] != null)
            {
                Label4.Text = "" + Session["A-_TotalUnit"].ToString();
            }
            if (Session["B+_TotalUnit"] != null)
            {
                Label5.Text = "" + Session["B+_TotalUnit"].ToString();
            }
            if (Session["B-_TotalUnit"] != null)
            {
                Label6.Text = " " + Session["B-_TotalUnit"].ToString();
            }
            if (Session["O+_TotalUnit"] != null)
            {
                Label7.Text = " " + Session["O+_TotalUnit"].ToString();
            }
            if (Session["O-_TotalUnit"] != null)
            {
                Label8.Text = " " + Session["O-_TotalUnit"].ToString();
            }
            if (Session["AB+_TotalUnit"] != null)
            {
                Label9.Text = "" + Session["AB+_TotalUnit"].ToString();
            }
            if (Session["AB-_TotalUnit"] != null)
            {
                Label10.Text = "" + Session["AB-_TotalUnit"].ToString();
            }

            

        }

and Web.Config changess
<system.web>
 <sessionState mode="InProc" cookieless="false" timeout="20" />

……

समाधान 1

अपना कोड देखें:

Session[BloodGroup1 + "TotalUnit1"] = TotalUnit1;

और

if (Session["A+_TotalUnit"] != null)
{
    Label3.Text = " " + Session["A+_TotalUnit"].ToString();
}

सूचकांक नाम समान नहीं हैं – “मान सेट करें” कोड “1” के साथ समाप्त होता है, “मान पढ़ें” कोड नहीं।

コメント

タイトルとURLをコピーしました