Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have got a code, on procedure Button_Click:

  protected void Button2_Click(object sender, EventArgs e)
            {
                using (SPWeb witryna = SPContext.Current.Web)
                {


                    // Dodawanie poszczególnych dni projektowych
                    SPListItemCollection listItems = witryna.Lists["Szczegoly"].Items;
                    SPListItem item = listItems.Add();
                    item["Kontrakt"] = TextBox1.Text;
                    item["Pracownik"] = TextBox2.Text;
                    item["Dzien"] = TextBox3.Text;
                    var selectedGroup = DropDownList2.SelectedItem;
                    item["Procenty"] = new SPFieldLookupValue(int.Parse(selectedGroup.Value), selectedGroup.Text);

                    string DateOnlyQuery = "<Where><Eq><FieldRef Name='{0}' /><Value Type='DateTime'>{1}</Value></Eq></Where>";
                  //  string FullQuery = "<Where><And><Eq><FieldRef Name='{0}' /><Value Type='DateTime'>{1}</Value></Eq><Eq><FieldRef Name='Pracownik' /><Value Type='Text'>{2}</Value></Eq></And></Where>";
                    string dateISO = SPUtility.CreateISO8601DateTimeFromSystemDateTime(Convert.ToDateTime(TextBox3.Text).ToLocalTime());

                    var query2 = new SPQuery();
                    query2.Query = String.Format(DateOnlyQuery, "Data", dateISO);
                    query2.ViewFields = "<FieldRef Name='Data' />";
                    query2.ViewFieldsOnly = true;
                    SPListItemCollection listaDniSwiatecznych = witryna.Lists["DR2013 Święta"].GetItems(query2);

                    foreach (SPListItem olistaDniSwiatecznych in listaDniSwiatecznych)
                    {
                        Label2.Text = olistaDniSwiatecznych["Kontrakt"].ToString();
                    }

                    // Zaktualizowanie wpisu w liscie projektów
                    item.Update();
                    this.TextBox1.Text = "";
                    this.TextBox2.Text = "";
                    this.TextBox3.Text = "";
                    Label2.Text = "Dodałeś nowy wpis";
                }
            }

If I try listing items on label in or not in Update Panel, I can't see anything. Any code doesn't listing on site. I don't see any writings. It's don't see label. Here of declaration of update panel:

`<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">

`

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I did it by erase a using method from this line:

SPWeb witryna = SPContext.Current.Web;

And now it's works good.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.