We help IT Professionals succeed at work.

How to Reload the page after Update (Datalist Databind)

TonyReba asked
Medium Priority
Last Modified: 2012-05-11
Using 16 datalist asp.net controls in my page I have programatically defined each updated command as below:

protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e) {

    //This codes repeats for all 16 datalist , diferent naming controls such as DataList2, Datalist3, etc.....

    String categoryID = DataList1.DataKeys[e.Item.ItemIndex].ToString();
    String dp_status = ((DropDownList)e.Item.FindControl("DropDownList1")).SelectedValue;
    //String txt_dept =

    SqlDataSource1.UpdateParameters["Id"].DefaultValue = categoryID;
    SqlDataSource1.UpdateParameters["Status"].DefaultValue = dp_status;
    // SqlDataSource1.UpdateParameters["Comment"].DefaultValue = ;
    //  SqlDataSource1.UpdateParameters["Census"].DefaultValue = ;


    DataList1.EditItemIndex = -1;


protected void DataList_ItemDataBound(object sender, DataListItemEventArgs e) {

    if (e.Item.ItemType == ListItemType.Item ||
      e.Item.ItemType == ListItemType.AlternatingItem)
        DataRowView drv = (DataRowView)(e.Item.DataItem);

        string status = drv.Row["Status"].ToString();
        if (status == "Available")
            e.Item.BackColor = System.Drawing.Color.LightGreen;
        if (status == "Assigned")
            e.Item.BackColor = System.Drawing.Color.LightSteelBlue;
        if (status == "BR")
            e.Item.BackColor = System.Drawing.Color.LightSalmon;


}//End Nt1 Change Colors

The problem is that once I update a datalist I loose the color change in my other Datalist controls.... Is there any way I can have all datalist rebind? or page reload after updating a record in any datalist?

f i insert new row / update exciting row, delete a row means automatically the gridview have to refresh. what i have to do//?....
Watch Question

For page reload, you could try doing a Response.Redirect("samepage.aspx"); to the same page to force a page reload/postback.

Or, you could use AJAX to do partial updates on the datalist that needs to be refreshed. Check the link below:


If you have 16 datalist on single page and you are changing row color on one datalist ItemDataBound event then how can others datalist row color can change as ItemDataBound events fire on the updated datalist. Try find datalist control by ID in this event and test it.

Else Response.Redirect to same page


Where. Do I place the redirect t
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.