AutoPostback Problem on the Grid

Last post 05-23-2009 12:49 AM by kaushalparik. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 05-22-2009 8:00 AM

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    AutoPostback Problem on the Grid

    Good Afternoon All

     For you to help me and understand my problem, i will have to explain everything in details.

    I have a usercontrol with a textbox. This textbox changes the values so am trapping the values on textchange and that is cool and working. I have set the textbox property to "Autopostback="true" in the usercontrol. 

    I have a Ultrawebgrid(Infragistics gridview version) on my Asp.net host page and now when the value of the textbox that i have trapped on textchange event changes, i want to bind the grid. I have method that is doing that , taking the value on textchange and assigning it  method and the method will bind the Grid based on the value. Now to be safe i have exposed the propert of the textbox "Autopostback" from the usercontrol like this

     

    public bool
     TextBoxAutoPostBack
    
    {
    
    
    get
     {
    
    
    return
     txtbxActvs.AutoPostBack;
    
    }
    
    
    set
    
    {
    
    txtbxActvs.AutoPostBack = 
    
    value
    ;

    and on the host page i have made it true like this

     

    <uc1:ActivityCtrl ID="ActivityCtrl1" runat="server" TextBoxAutoPostBack=true ActivityViewMode="Staff" KeepApart="false" OnLoad="ActivityCtrl1_Load" EnableViewState="true" />

    And Here is the Photo to Explains what is happening

    Thank you

    www.itsabacus.co.za
    Experts in University Timetabling
  •  Advertisement

    Featured Advertisement

     
  • 05-22-2009 8:08 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    Ok. What is the question?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-22-2009 8:21 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    My Problem is that i when the textchange is fired , i need that grid to show me records, but it seems there is something wrong there , because i need to manualy click somewhere else. Another this i did not mention is that the  lefthand side Cotrol is inside an Updatecontrol and i have another update control that raps the usercontrol and the other controls on the right hand side.

     

    Thanks for your reply.

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 8:36 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    Is the Grid in the same UpdatePanel?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-22-2009 8:40 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    Thanks for your Reply. All the Controls on the Right hand side  have their own update panel and the grid is part of them and the is another update panel that wraps all the Control including the Usercontrol.

     

    Thanks

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 8:48 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    When you enter the text into the textbox and the associated event is fired on the server, then you have to refresh the second UpdatePanel of the Grid. You can do this via:

    MyGridUpdatePanel.Update();

    Let me know if that helps!

     

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
    Filed under: ,
  • 05-22-2009 9:10 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    I would like to take this chance to thank you for what you have done for me.

    Which one must be Updated and The one that Wraps All the Controls including the usercontrol or the one that has a grid. and when should it be updated. i have tried to put the update part inside a Function that binds the grid after every binding is done, but still nothing is happening.

    One more thing , in order to use the Update for the Updatepanel i need to set my updatepanel's property "Condition Mode" to "Conditional", i have done that too

     


    Thanks

     

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 9:22 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    You would need to put the code into the TextChanged event. Can you try that?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
    Filed under: ,
  • 05-22-2009 9:49 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    Nothing is happening , still doing the same thing.If i click a button it shows the records on a grid, is it posible to initiate postback inside the  updatepanel ?

     

    i have seen this links

    http://geekswithblogs.net/ranganh/archive/2007/05/16/112526.aspx

    has this have something to do with my problem ?

     

       <Triggers>
                <%--<asp:PostBackTrigger ControlID="Button1" />--%>
                <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
            </Triggers

     

    Thanks

     

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 9:54 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    Well, this is a way to solve the problem as well. Though I have not worked for a while with UpdatePanels and tend to avoid them as much as possible. I use direclty javascript along with the ScriptManager to make my ajax calls. But thats for another post :)

    Can you post your textChanged event code (only the relevant part)?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-22-2009 10:03 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    Ok , On the Textchanged part remember am targeting the textchanged of the usercontrol. so in the usercontrol i created an event handler like this

    public event EventHandler TextChanged;

    and in the textchanged event of the textbox i have this code

         

    if (TextChanged != null)
            {
                TextChanged(this, EventArgs.Empty); //Raise Event
            }

    and in my page , that host the usercontrol i have this

     

    override protected void OnInit(EventArgs e)
        {
            this.ActivityCtrl1.TextChanged += new EventHandler(ActivityCtrl1_TextChanged);
            InitializeComponent();

            base.OnInit(e);
        }

    and that created a function for me to bind the grid and it looked like this

     void ActivityCtrl1_TextChanged(object sender, EventArgs e)
        {
            Bind_Grid_For_Staff();
            UpdatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional;
            UpdatePanel1.Update();

        }

    this is the textchange on the host page

    Thank you

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 10:20 AM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    Weird. This should be working. Can you create a very simple demo project and upload it somewhere?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-22-2009 11:51 AM In reply to

    • Vuyiswamb
    • Top 100 Contributor
    • Joined on 05-22-2009
    • South Africa
    • Wannabe Slacker
    • Points 90

    Re: AutoPostback Problem on the Grid

    Good Evening


    Thank you once more. i have created a sample project and i have seen that the problem is that i trapped the textchange, now if the system is only setting the textbox to a value this is where it gives a problem , but if you type it, it does autopostback. but in my case a user will not be able to type anything , when he select something like a button as i have provided in the sample project, the button will assign a value to a textbox and the grid must be updated accordingly.

    please find a sample project on this


    http://www.vbforums.com/attachment.php?attachmentid=71123&d=124300730

     

    Thank you

     

    www.itsabacus.co.za
    Experts in University Timetabling
  • 05-22-2009 12:55 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    Why are you creating a new event for TextChanged? Why dont you use the default one?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 05-22-2009 1:02 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,091
    • MVP

    Re: AutoPostback Problem on the Grid

    OK, I changed your code. I am not sure it was supposed to be like this, however it will give you some ideas. Press the button "One" few times and you will see that the second grid gets populated. The Zip is attached.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
Page 1 of 2 (16 items) 1 2 Next >