Click here to Skip to main content
14,825,842 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hello everyone!

I have an UpdatePanel which has a Repeater Control in which another Repeater Control is nested. Within this nested Repeater Control,I have a TextBox for adding comments and a Button to Submit it.

On button click, the UpdatePanel is triggered and in the Repeater2_ItemCommand event, I have saved the TextBox value in database and then called Repeater2.DataBind().

According to me, the Repeater must fetch the new values from the DataBase and display them. But it doesn't happen in that manner. On Button Click, the data is being saved but the page is left blank. I can view the data only when I visit the page link again(as Refresh also doesn't work) after adding the comment.

Please tell me what to do!

Code for repeater:
protected void Repeater2_ItemCommand(object sender, RepeaterCommandEventArgs e)
        lblMsg.Visible = false;
        TextBox tb = new TextBox();
        id = e.CommandArgument.ToString();
        column1 = ((TextBox)e.Item.FindControl("txtCol1")).Text.Trim();
        column2 = ((TextBox)e.Item.FindControl("txtCol2")).Text.Trim());
        cmd = new SqlCommand("update tab set col1=@col1,col2=@col2 where id=@id", con);
        cmd.Parameters.AddWithValue("@id", id);
        cmd.Parameters.AddWithValue("@col1", column1);
        cmd.Parameters.AddWithValue("@col2", column2);
        int rwcnt = cmd.ExecuteNonQuery();
        if (rwcnt <= 0)
            lblMsg.Visible = true;
Updated 8-Feb-12 2:31am
loctrice 20-Jan-12 17:18pm
You need to post some of your code I think. Things to check that I am aware of right off, make sure that you are doing your databinding in the correct places (not just in the !postback)

Before DataBind you need to assign DataSource to the repeater, that is missing
Reapeter2.DataSource =source;
Tech Code Freak 8-Feb-12 11:58am
Yes, that's it! How did I ever forget that?
Thank you so much!
Please send your code behind for data bind to repeator control.
Anuja Pawar Indore 8-Feb-12 8:58am
Use comment block, this is answer section

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900