[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

AutoPostBack in Asp.net

Hi,

My question is related to post back event on asp.net page.
I have several controls on a single web page like listbox, gridview and dropdownlists, aspbuttons.
My question is, whenver I make changes to any of the controls (on the client side - through browser), eg, if I select an item from the dropdownlist, the page is shown as blank i.e., it clears all the other entries in gridview and listbox as well.
To solve this problem, I need to call all the functions (to fill in the data in those controls again) everytime I take some action with a single control on the page (ie., post back).

Is there any way to prevent this from happening? For eg, can I put all those controls in seperate sections so that when any action is taken related to a particular control, it refreshes data in that particular control only and the state of all other controls on the page remains the same.

Please help.
0
Tina_Bhole
Asked:
Tina_Bhole
  • 18
  • 14
  • 7
  • +1
2 Solutions
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi, I think that you has disabled the page EnableViewState property, set it to True.
0
 
Tina_BholeAuthor Commented:
EnableViewState property of the page is already true.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Maybe you have it disabled in yours controls? They has the EnableViewState property too.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Carlos VillegasFull Stack .NET DeveloperCommented:
If your problem persist, can you show your aspx code?
0
 
Tina_BholeAuthor Commented:
I have set EnableViewState property of all my controls to true but still, particularly, when I change dropdownlist item, it clears all the entries from my girdview. Following is the aspx code:

<asp:DropDownList ID="Rulecondition" runat="server" AutoPostBack="true" EnableViewState="true" CssClass="DropDownList1" OnSelectedIndexChanged="ShowMore">
                                <asp:ListItem>after</asp:ListItem>
                                <asp:ListItem>before</asp:ListItem>
                                <asp:ListItem>between</asp:ListItem>
                            </asp:DropDownList>

 <asp:GridView runat="server" ID="CCRHeaderDetails" CssClass="GV" EnableViewState="true" OnRowDataBound="SelectCCRHeaderRow"></asp:GridView>
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi again, it looks OK, can you show the code behind? Remove any sensitive data. Also, please add a button and run your page again, click the button, yours controls lost the data when you click that button?
0
 
Tina_BholeAuthor Commented:
Hi, I removed the AutoPostBack property from the DropDownList and it worked fine. But , I also wanted a lable and a textbox enabled once "between" is selected from dropdownlist, which is not happening now.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi you must enable the autopostback on the dropdownlist to accomplish that, please can you show me your c# code?
0
 
Alfred A.Commented:
Since your dropdownlist is set to autopostback, any changes in the dropdownlist will generate a postback and refresh everything in your page.  You need to rebind your GridView if a postback occurs.  Something like:

protected void Page_Load(object sender, EventArgs e)
{
      GridView1.DataSource = <your data source>;
      GridView1.DataBind();
}

Or, you could use partial page updates using AJAX by putting your GridView and ListBoxes in an Update Panel control.  Check the link below:

http://msdn.microsoft.com/en-us/library/bb399001.aspx
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
@Alfred1 that is wrong, why do you say that? You don't need to rebind anything at least that you want to display a different data in that control, that is the viewstate purpose. Are you saying that we need to rebind the control with each postback? That is absolutely not true.
0
 
Alfred A.Commented:
@yv989c:

Well, I am just speaking within the context of the issue and this is not exactly wrong.  

I should have said "to bind the data again".  This is normally true if viewstate is switch off.

In actual practice you don't rebind the control with each postback.  However, there is no basis to determine what exactly is she doing in the code behind.  What I am just saying is that she needs to bind the data again.

In her case, I have a feeling that the combination of dropdownlist and gridview is used in a master-detail where you select an item in dropdownlist, you used the selected item as a parameter in retrieving data, and then bind the data to the gridview.

@Tina_Bhole:

Can you please provide us a code snippet of your code-behind so that we can determine what exactly is wrong with your setup and to let @yy989c calm down?   :-)
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Ok Alfred1, then I misunderstood your post, sorry, english is not my first language so... I hope you understand.... well if you read her problem she is saying that with a postback from her dropdownlist any binded control lost its data.. so the first thing that cross my mind was that she disabled the viewstate but she said that is is enabled... yes, we need to see what is happening in her code behind, specifically in the DropDownList1 SelectedIndexChanged event I think.
0
 
Alfred A.Commented:
@yv989c:

And another thing I forgot to mention, I was talking on a conceptual level in my post at ID: 35703743.  If you noticed I didn't even touch with her other controls that have problems as well such as the listbox.  

@Tina_Bhole:

Can you also could provide your complete HTML Source as well if possible?
0
 
Alfred A.Commented:
@yv989c:

No worries, mate!  Yes.  You are right with respect to the viewstate.   I will just wait for her code snippet then.
0
 
Tina_BholeAuthor Commented:
Hi, Thanks both of you for taking time to find a solution for  me.

Followin is the aspx code

    <asp:ScriptManager ID="SM1" runat="server"></asp:ScriptManager>
    <table class="displaytable">
        <tr>
            <td colspan="2">                                                                  
                <asp:Label runat="server" ID="CCRInputFileNameLabel" CssClass="BoldText"></asp:Label>
                <asp:GridView runat="server" ID="CCRContents" CssClass="textarea"></asp:GridView>
            </td></tr>    
         <tr><td>
                <table class="displaytable1">
                  <tr class="rowdisplay">
                        <td>
                            <asp:RadioButton runat="server" ID="RCCRH" Checked="true" GroupName="RGCCR" AutoPostBack="true" Text="CCR Header" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
                            <asp:RadioButton runat="server" ID="RCCRD" Checked="false" GroupName="RGCCR" AutoPostBack="true" Text="CCR Details" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
                        </td>    
                           
                        <td><asp:GridView runat="server" ID="CCRList" CssClass="listBox" OnRowDataBound="SelectListRow"></asp:GridView></td>
                        <asp:UpdatePanel ID="UP1" runat="server">
                                <ContentTemplate>
                                        <td><asp:DropDownList ID="Rulecondition" runat="server" EnableViewState="true" CssClass="DropDownList1" OnSelectedIndexChanged="ShowMore">
                                                <asp:ListItem>after</asp:ListItem>
                                                <asp:ListItem>before</asp:ListItem>
                                                <asp:ListItem>between</asp:ListItem>
                                            </asp:DropDownList></td>
                                        <td><asp:Label runat="server" ID="l1" CssClass="lbl">word</asp:Label></td>
                                        <td><asp:TextBox runat="server" ID="Ruleword1" CssClass="textEntry2"></asp:TextBox></td>
                                        <td><asp:Label runat="server" ID="labeland" Text="and" CssClass="lbl"></asp:Label></td>  
                                        <td><asp:TextBox runat="server" ID="Ruleword2" CssClass="textEntry2" ></asp:TextBox></td>  
                                        <td><asp:Label runat="server" ID="labelon" Text="on Line No." CssClass="lbl"></asp:Label></td>      
                                        <td><asp:TextBox runat="server" ID="txtlineno" CssClass="textEntry1"></asp:TextBox></td>      
                                </ContentTemplate>
                        </asp:UpdatePanel>
                       
                        <td><asp:Button  runat="server" ID="AddColumn" CssClass="aspbutton2" Text="Add Column" OnClick="AddColumnDetails"/></td>
                   </tr>  
                   <tr>
                       <%-- <td colspan="10">
                            <asp:GridView runat="server" ID="CCRHeaderDetails" CssClass="GV" OnRowDataBound="SelectCCRHeaderRow">
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:CheckBox runat="server" ID="chkH" onClick="SelectCCRHeaderRow(this)" />
                                        </ItemTemplate>    
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Column Name">
                                        <ItemTemplate>
                                            <asp:Label ID="ColumnName" runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="CCR Header Rule Entry">
                                        <ItemTemplate>
                                            <asp:Label ID="HeaderRule" runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </td>--%>
                        <td colspan="10">
                         <asp:GridView runat="server" ID="CCRHeaderDetails" CssClass="GV" EnableViewState="true" OnRowDataBound="SelectCCRHeaderRow"></asp:GridView>
                        </td>
                   </tr>
                    <tr>
                        <td colspan="10">
                            <asp:Button  runat="server" ID="removeHeaderentry" Text="Remove Entry" CssClass="aspbutton2" OnClick="RemoveHeaderEntry"/>
                        </td>
                   </tr>  
                    <tr>
                        <td colspan="10">
                            <asp:GridView runat="server" ID="CCRDDetails" CssClass="GV" EnableViewState="true" OnRowDataBound="SelectCCRDetailsRow"></asp:GridView>
                        </td>
                   </tr>
                   <tr>
                        <td colspan="10">
                            <asp:Button  runat="server" ID="removeDetailsentry" Text="Remove Entry" CssClass="aspbutton2" OnClick="RemoveDetailsEntry"/>
                        </td>
                   </tr>  
                </table>
         </td></tr>    
   </table>
</asp:Content>
0
 
Tina_BholeAuthor Commented:
This is my C# code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading;
using System.Web;
using System.Drawing;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using NHDAL;
using TAPS.GlobalVariables;
using System.Data;
using System.Data.OleDb;

namespace TILES
{
    public partial class Generate_CCR_Rule : System.Web.UI.Page
    {
       
        string[] CCRHeaders= new string[13];
        string[] CCRDetails = new string[26];

        DataTable DT1 = new DataTable(); // Linked with GlobalClass.CCRHeaderArr
        DataRow DR1;
       
        DataTable DT2 = new DataTable(); // Linked with GlobalClass.CCRDetailsArr
        DataRow DR2;
             
       protected void Page_Load(object sender, EventArgs e)
        {
           //Filling  Gridview  CCRContents with first 20 lines of the Selected File Contents

            DataTable DT = new DataTable();
            DT.Columns.Add(new DataColumn("Line", typeof(Int32)));
            DT.Columns.Add(new DataColumn("CCR Contents", typeof(string)));
            DataRow DR;

            CCRInputFileNameLabel.Text = GlobalClass.InputFile;
            StreamReader SR = new StreamReader(GlobalClass.InputFile);

            for (int i = 0; i < 20; i++)
            {
                DR = DT.NewRow();
                DR["Line"] = i + 1;
                DR["CCR Contents"] = SR.ReadLine();
               
                DT.Rows.Add(DR);
            }

            SR.Close();
            SR = null;

            CCRContents.DataSource = DT;
            CCRContents.DataBind();

           //************************************************************************************

            FillCCRHeaders(); // fills the array with CCR Header column names
            FillCCRDetails(); // fills the array with CCR Details column names

            //By Default, RCCRH radiobutton will be checked on Form Load and the List will be loaded with the column names from the array CCRHeaders
            RCCRH.Checked = true;
            RCCRD.Checked = false;
            CCRList.DataSource = CCRHeaders;
            CCRList.DataBind();

           //***********************************************************************************

            DT1.Columns.Add(new DataColumn("Column Name", typeof(string)));
            DT1.Columns.Add(new DataColumn("CCR Header Rule Entry", typeof(string)));

            CCRHeaderDetails.DataSource = DT1;
            CCRHeaderDetails.DataBind();
           
           //***********************************************************************************

            DT2.Columns.Add(new DataColumn("Column Name", typeof(string)));
            DT2.Columns.Add(new DataColumn("CCR Details Rule Entry", typeof(string)));

            CCRDDetails.DataSource = DT2;
            CCRDDetails.DataBind();
        }

        protected void AddCCRColumns(object sender, EventArgs e)
        {
            if (RCCRH.Checked)
            {
                RCCRD.Checked = false;
                CCRList.DataSource = CCRHeaders;
                CCRList.DataBind();
            }

            if (RCCRD.Checked)
            {
                RCCRH.Checked = true;
                CCRList.DataSource = CCRDetails;
                CCRList.DataBind();
            }
        }

       
        protected void ShowMore(object sender, EventArgs e)
        {
            Ruleword2.Text = "";

            if (Rulecondition.SelectedIndex == 2)
            {
                labeland.Enabled = true;
                Ruleword2.Enabled = true;
            }
            else
            {
                labeland.Enabled = false;
                Ruleword2.Enabled = false;
            }
        }

        protected void AddColumnDetails(object sender, EventArgs e)
        {
            string S="";

            if (Rulecondition.Text == "between")
            {
                S = Rulecondition.Text + " " + l1.Text + " " + Ruleword1.Text + " " + labeland.Text + " " + Ruleword2.Text + " " + labelon.Text + " " + txtlineno.Text;
            }
            else
            {
                S = Rulecondition.Text + " " + l1.Text + " " + Ruleword1.Text + " " + labelon.Text + " " + txtlineno.Text;
            }

            if (RCCRH.Checked == true)
            {
                GlobalClass.CCRHeaderArr[GlobalClass.HeaderCounter, 0] = CCRList.Rows[int.Parse(hdnListitem.Value)].Cells[0].Text;
                GlobalClass.CCRHeaderArr[GlobalClass.HeaderCounter, 1] = S;
                GlobalClass.CCRHeaderArr[GlobalClass.HeaderCounter, 2] = hdnListitem.Value;

                for (int i = 0; i <= GlobalClass.HeaderCounter; i++)
                {
                    DR1 = DT1.NewRow();
                    DR1["Column Name"] = GlobalClass.CCRHeaderArr[i, 0];
                    DR1["CCR Header Rule Entry"] = GlobalClass.CCRHeaderArr[i, 1];
                    DT1.Rows.Add(DR1);
                    CCRList.Rows[int.Parse(GlobalClass.CCRHeaderArr[i,2])].BackColor=System.Drawing.ColorTranslator.FromHtml("#EBEDED");
                }
                                               
                CCRHeaderDetails.DataSource = DT1;
                CCRHeaderDetails.DataBind();
                GlobalClass.HeaderCounter++;
            }
            else if (RCCRD.Checked == true)
            {
                GlobalClass.CCRDetailsArr[GlobalClass.DetailsCounter, 0] = CCRList.Rows[int.Parse(hdnListitem.Value)].Cells[0].Text;
                GlobalClass.CCRDetailsArr[GlobalClass.DetailsCounter, 1] = S;
                GlobalClass.CCRDetailsArr[GlobalClass.DetailsCounter, 2] = hdnListitem.Value;

                for (int i = 0; i <= GlobalClass.DetailsCounter; i++)
                {
                    DR2 = DT2.NewRow();
                    DR2["Column Name"] = GlobalClass.CCRDetailsArr[i, 0];
                    DR2["CCR Details Rule Entry"] = GlobalClass.CCRDetailsArr[i, 1];
                    DT2.Rows.Add(DR2);
                    CCRList.Rows[int.Parse(GlobalClass.CCRHeaderArr[i,2])].BackColor = System.Drawing.ColorTranslator.FromHtml("#EBEDED");
                }

                CCRDDetails.DataSource = DT2;
                CCRDDetails.DataBind();
                GlobalClass.DetailsCounter++;
            }

          S=null;
       }

        protected void SelectListRow(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.border=' solid #BFCFFE';";
                e.Row.Attributes["onmouseout"] = "this.style.border='none';";
                e.Row.Attributes["onclick"] = "GridView_CCRListSelect(this," + e.Row.RowIndex + ");";
            }
           
        }

        protected void SelectCCRHeaderRow(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.border=' solid #BFCFFE';";
                e.Row.Attributes["onmouseout"] = "this.style.border='none';";
                e.Row.Attributes["onclick"] = "GridView_selectRowH(this," + e.Row.RowIndex + ");";
            }
        }

        protected void SelectCCRDetailsRow(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.border=' solid #BFCFFE';";
                e.Row.Attributes["onmouseout"] = "this.style.border='none';";
                e.Row.Attributes["onclick"] = "GridView_selectRowD(this," + e.Row.RowIndex + ");";
            }
        }
        protected void FillCCRHeaders()
        {
            CCRHeaders[0] = "Some text.";
            CCRHeaders[1] = "Some text.";
            CCRHeaders[2] ="Some text.";
            CCRHeaders[3] ="Some text.";
            CCRHeaders[4] ="Some text.";
            CCRHeaders[5] = "Some text.";
         
        }

        protected void FillCCRDetails()
        {
            CCRDetails[0] = "Some text.";
            CCRDetails[1] = "Some text.";
            CCRDetails[2] = "Some text.";
            CCRDetails[3] = "Some text.";
            CCRDetails[4] = "Some text.";
            CCRDetails[5] ="Some text.";
           
        }

   
        protected void RemoveHeaderEntry(object sender, EventArgs e)
        {

           // GridViewRow row = CCRHeaderDetails.Rows[int.Parse(hdnHSelect.Value)];
            GridViewRow row = CCRHeaderDetails.SelectedRow;
            DataRow dr = (row.DataItem as DataRowView).Row;
            DT1.Rows.Remove(dr);
            CCRHeaderDetails.DataSource = DT1;
            CCRHeaderDetails.DataBind();
        }

        protected void RemoveDetailsEntry(object sender, EventArgs e)
        {

            DataTable DT2 = new DataTable();
            //DR2 = DT2.NewRow();
            //DR2=DT2.Rows[int.Parse(hdnDSelect.Value)];
            //DT2.Rows.Remove(DR2);
            //CCRDDetails.DataSource = DT2;
            //CCRDDetails.DataBind();

        }
    }
       
}
0
 
Tina_BholeAuthor Commented:
Hi yv989c and Alfred1,

@Alfred1, I followed your suggestion..I added asp:ScriptManager to my aspx code but, I have to click the  "Add" button twice to get the result. i.e., it takes 2 post back events for changes to take place.

Any suggestions ..why this could be happening?

Many Thanks.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi Tina, first, replace your Page_Load method with this code:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //Filling  Gridview  CCRContents with first 20 lines of the Selected File Contents

        DataTable DT = new DataTable();
        DT.Columns.Add(new DataColumn("Line", typeof(Int32)));
        DT.Columns.Add(new DataColumn("CCR Contents", typeof(string)));
        DataRow DR;

        CCRInputFileNameLabel.Text = GlobalClass.InputFile;
        StreamReader SR = new StreamReader(GlobalClass.InputFile);

        for (int i = 0; i < 20; i++)
        {
            DR = DT.NewRow();
            DR["Line"] = i + 1;
            DR["CCR Contents"] = SR.ReadLine();

            DT.Rows.Add(DR);
        }

        SR.Close();
        SR = null;

        CCRContents.DataSource = DT;
        CCRContents.DataBind();

        //************************************************************************************

        FillCCRHeaders(); // fills the array with CCR Header column names
        FillCCRDetails(); // fills the array with CCR Details column names

        //By Default, RCCRH radiobutton will be checked on Form Load and the List will be loaded with the column names from the array CCRHeaders
        RCCRH.Checked = true;
        RCCRD.Checked = false;
        CCRList.DataSource = CCRHeaders;
        CCRList.DataBind();

        //***********************************************************************************

        DT1.Columns.Add(new DataColumn("Column Name", typeof(string)));
        DT1.Columns.Add(new DataColumn("CCR Header Rule Entry", typeof(string)));

        CCRHeaderDetails.DataSource = DT1;
        CCRHeaderDetails.DataBind();

        //***********************************************************************************

        DT2.Columns.Add(new DataColumn("Column Name", typeof(string)));
        DT2.Columns.Add(new DataColumn("CCR Details Rule Entry", typeof(string)));

        CCRDDetails.DataSource = DT2;
        CCRDDetails.DataBind();
    }
}

Open in new window

Your data bind code will run only on the first load of your page.
0
 
Tina_BholeAuthor Commented:
and also, now that you know my code in detail, could I please add one more question to this post if that's ok?

These are the two radio buttons on my page:

 <td>
                            <asp:RadioButton runat="server" ID="RCCRH" Checked="true" GroupName="RGCCR" AutoPostBack="true" Text="CCR Header" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
                            <asp:RadioButton runat="server" ID="RCCRD" Checked="false" GroupName="RGCCR" AutoPostBack="true" Text="CCR Details" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
</td>    

For some reason, the lable(text) of the radio button and the radio button itself are displayed on 2 seperate rows. Is there any way I can make them show on one single line . ie., the radio button label infront of the radio button?
0
 
Tina_BholeAuthor Commented:
Hi There,

I have added if(!IsPostBack) to my page load event now.
Another problem, now all of a sudden  I am getting this error for the scriptmanager I have added,

Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi, try with:
<td style="white-space: nowrap;">
                            <asp:RadioButton runat="server" ID="RCCRH" Checked="true" GroupName="RGCCR" AutoPostBack="true" Text="CCR Header" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
                            <asp:RadioButton runat="server" ID="RCCRD" Checked="false" GroupName="RGCCR" AutoPostBack="true" Text="CCR Details" TextAlign="Left" OnCheckedChanged="AddCCRColumns"/>
</td>  

0
 
Tina_BholeAuthor Commented:
Hi yu989c,

Sorry, it didn't work. The radio buttons and the text are still showing on seperate lines.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hi, did you remove that reference from your project?

Try rebuilding your project
OR
Try adding that reference, in the solution explorer, Right click on your project, click on add reference, .NET tab, look for System.Windows
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
What web browser are you using? IE8, IE9, FF, Chrome?
0
 
Tina_BholeAuthor Commented:

I did add the reference System.Windows.Forms, it's still giving me an error.
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Not that, I just said System.Windows, it is a assembly required for silverlight I think.
0
 
Tina_BholeAuthor Commented:
@yv989c, I could not find any reference just called as System.Windows under .Net tab.
I already have 2 silverlight applications running on my website. They are working fine without adding System.Windows.forms.
0
 
Tina_BholeAuthor Commented:
I am using IE
0
 
Tina_BholeAuthor Commented:
IE8
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
ok, can you click the compatibility mode?

2. When this error stared to raise? what you did before?
Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

Also can you post a screen shot of your screen with that error?
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
or please post a screen shot of your group boxes and the error too, can you?
0
 
Alfred A.Commented:
OK.  For the partial page updates, try having this structure in your code.  I will just provide a summary example below:

Assuming that we have GridView1 and GridView2 and Dropdownlist1 in your page and if postback occurs through selection Dropdownlist1, you only want to refresh GridView1 automatically and leave the others not updated.  You can do it this way below.  Don't forget the UpdateMode="Conditional"

<asp:UpdatePanel ID="UP1" runat="server" UpdateMode="Conditional">
        <your dropdownlist1>
        <your GridView1>
</asp:UpdatePanel>

Now, let say you want to update or refresh GridView2 depending on conditions and not at once, you could add another update panel and call the Update Method inside your code behind.

<asp:UpdatePanel ID="UP2" runat="server" UpdateMode="Conditional">
        <your GridView2>
</asp:UpdatePanel>

In your code behind, you could capture the SelectedIndexChanged and refresh GridView2.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    //Do something with your data based on selected item and maybe bind your data again after modification.
   if(conditionOK)
   {
        UP2.Update();
    }
}


Here is a reference on UpdateMode:

http://codeclimber.net.nz/archive/2007/05/24/updatemode-default-value-for-the-updatepanel-is-always.aspx




0
 
Tina_BholeAuthor Commented:
Hi Alfred1,

Thanks for posting that code.
I have made necessary changes to my code accordingly. But, I am still getting the error related to ScriptManager.

@yv989c, pls find the snap shot of the error attached.
Capture2.PNG
Capture.PNG
0
 
dexion432Commented:
copy the system.windows assembly into the bin folder.
0
 
Tina_BholeAuthor Commented:
Hi dexion432, I copied the System.Windows.dll  from C:\Program Files (x86)\Microsoft Silverlight\4.0.60310.0 to bin folder of my application.

The above  mentioned error is gone  now. But, another error came up out of the blue.
I have no idea in what way it is related?
Capture3.PNG
0
 
Tina_BholeAuthor Commented:
This error occured when UI clicked Addcolumn button (AddColumnDetails procedure)
0
 
Tina_BholeAuthor Commented:
Oh! now I understand
Because of the ConditionalUpdate property of UpdatePanel
I added these statements and the error was gone.

                DT1.Columns.Add(new DataColumn("Column Name", typeof(string)));
                DT1.Columns.Add(new DataColumn("CCR Header Rule Entry", typeof(string)));

Thanks again all of you for helping
0
 
Alfred A.Commented:
Check the link below.  This has been reported to Microsoft.  There is workaround in there to resolve the problem by installing System.Windows.dll into the GAC

https://connect.microsoft.com/VisualStudio/feedback/details/600553/after-upgrading-to-net-4-0-im-getting-the-exception-could-not-load-file-or-assembly-system-windows-version-2-0-5-0-once
0
 
Alfred A.Commented:
So, is your problem solved.  Everything OK now?
0
 
Tina_BholeAuthor Commented:
I was truly loving it.
It was amazing how quickly I was getting response from these experts.
They all did their best to help me out.

Thankyou all.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 18
  • 14
  • 7
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now