tags:

views:

25

answers:

1

on my save button i want to clear all values of form i did the following for CheckBoxList beach.

But it doesn't work. Why so, it doesn't make values clear for checkbox list

Branch is filled like this:

protected void course_SelectedIndexChanged(object sender, EventArgs e)
{
    try
    {
        int courseId = Convert.ToInt32(course.SelectedValue);
        DataTable dt;
        dt = placementManager.GetBranchList(courseId);
        if (dt.Rows.Count != 0)
        {
            Branch.DataSource = dt;
            Branch.DataTextField = "branch_name";
            Branch.DataValueField = "branch_id";
            Branch.DataBind();                
        }
        Btnsave.Visible = false;
        GridView1.Visible = false;
    }
    catch (Exception ex)
    {
        COMMON.logger.Error("Error on course_SelectedIndexChanged:CompanySelected.aspx.cs", ex);
    }

    if (b)
    {
        gridNotExist.Text = "Records Successfully inserted for the displayed table, To insert new records select new entries";
        this.ViewState.Remove("selectedList");
        this.ViewState.Remove("dt");
        Session.Abandon();
        passout.SelectedIndex = 0;
        company.SelectedIndex = 0;
        txtpackage.Text = "";
        course.SelectedIndex = 0;

        Branch.DataSource = null;
        Branch.DataBind();
        vistDate.Text = "";
        txtvenue.Text = "";
        //GridView1.Visible = true;
    }
}

aspx page has, of course, branch like this:

<asp:UpdatePanel id="update" runat="server">
     <contenttemplate>
         <td>
             <asp:DropDownList ID="course" runat="server" AutoPostBack="True" OnSelectedIndexChanged="course_SelectedIndexChanged" />
             <asp:CustomValidator ID="coursenecessaryForSaveButton" runat="server" ControlToValidate="course" ErrorMessage="Select A Course" OnServerValidate="coursenecessaryForSaveButton_ServerValidate" ValidationGroup="save" />
         </td>
         <td>
             <asp:CustomValidator ID="courseNecessary" runat="server" ErrorMessage="Select A Course" OnServerValidate="courseNecessary_ServerValidate" ValidationGroup="verify" />
         </td>
         <td style="width: 101px">
             Branch Name*
         </td>
         <td style="width: 126px">                        
             <asp:CheckBoxList id="Branch" runat="server" />
         </td>
    </contenttemplate>    
</asp:UpdatePanel>
A: 
<asp:CheckBoxList id="Branch" runat="server" >

is in a different UpdatePanel to the control which is triggering the asynchronous postback - and firing your eventhandler: course_SelectedIndexChanged.

Put the Checkbox List inside the UpdatePanel with id="update" and it will solve your problem.

Still, i would consider refactoring your HTML (and code while you're at it).

For instance - you have two UpdatePanel's - why?

The second one has nothing in it besides checkboxes. The purpose of an UpdatePanel is to dynamically update portions of a page (ie dynamic information) without a full postback.

Having nothing but static controls (checkboxes) inside an UpdatePanel isn't really serving any purpose.

However, my above answer is a stab in the dark at what you're after. You're code-behind code does'nt really make sense:

if (b == true)

Where is b defined??

Branch.DataSource = null
Branch.DataBind()

What are you binding??

RPM1984
i edited the above aspx code like that but now post back taking place.i am poor in update panel concept please enlighten on the above code please
NoviceToDotNet
Boolean b = placedStudentManager.SaveSelectdStudent(gridviewTbl);b is just defined above the code for true false value
NoviceToDotNet
I am binding checkBoxList as mentioned above in .cs file
NoviceToDotNet
does update panel doesnt recognise td, tr it does a problem to update panel
NoviceToDotNet
You're asking way too many questions. Suggest you have a good read of the ASP.NET UpdatePanel - http://msdn.microsoft.com/en-us/magazine/cc163413.aspx
RPM1984