Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Databind not executed, why?

$
0
0

Hi

I have one button inside a bootstrap panel and I want to insert one record. here is my code:

<div class="panel-footer"><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:Button ID="Button4" runat="server" Text="Adicionar" OnClick="Adiciona_Click" /></ContentTemplate>                            </asp:UpdatePanel></div>

and my c# code:

 protected void Adiciona_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in GridView2.Rows)
        {
            CheckBox chkbox = (CheckBox)row.FindControl("CheckBox2");
            if (chkbox.Checked == true)
            {
                SqlDataSource1.InsertParameters.Clear();
                SqlDataSource1.InsertCommand = "insert into turmas (designacao,aluno_id,nome_aluno,id_prof,nome_prof) values (?,?,?,?,?)";
                SqlDataSource1.InsertParameters.Add("@a", lblTurma.Text);
                SqlDataSource1.InsertParameters.Add("@a", row.Cells[1].Text);
                SqlDataSource1.InsertParameters.Add("@a", Server.HtmlDecode(row.Cells[2].Text));
                SqlDataSource1.InsertParameters.Add("@a", "1");
                SqlDataSource1.InsertParameters.Add("@a", "Professor de teste");
                SqlDataSource1.Insert();
            }
        }
        SqlDataSource2.DataBind();
        GridView1.DataBind();        
        ModalPopupExtender1.Hide();
    }

My problem:

The record is inserted but the databind are not executed. Why?

thank you


Viewing all articles
Browse latest Browse all 5678

Trending Articles