Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2006, 04:03 PM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid rebinding to intial state.please help!!

Hi,
     I have a dropdownlist with values like s1,p1. Always in the dropdownlist s1 value would be selected(default setting).The datagrid with all the records corresponding to s1 are displayed.Now when i select the p1 value from the dropdown list ,the datagrid with all the records corresponding to p1 are displayed.Below the datagrid i have pages like 1 2 3 4 ..for example,when i am on the third page with p1 in the dropdownlist i pick an userid value in the datagrid ,i edit the values in the update screen corresponding to that userid.I click the save button .Now the changes are saved to the database ,but after clicking the save button it should take me back to the third page where the datagrid table is there,but instead it goes back to the intial screen with dropdownlist having s1 selected.

     I have the userid column in the datagrid to be a hyperlinkcolumn.Onclicking the userid ,the page_load event gets fired.In the page_load event,I have if(!Page.IsPostBack) and i have the function call for dropdownlist default setting and binddata() function.In the savebutton function ,i have a call for binddata( ).Onclicking the save button the updated data gets saved in the database,but the datagrid is set to the initial or default setting.Please let me know how to fix this problem.what changes should i make to work correctly?

code:
Code:
private void Page_Load(object sender, System.EventArgs e)
        {
                txtFocus.Value="0";
                EditUsers.Enabled =false;
                m_User = new BusinessLogin();  
                cacheUser = new PTSCache();       
                CheckSession();

                if(!Page.IsPostBack)
                {
                    EditUsers.Enabled=false; 
                    tsUserMaintenance.SelectedIndex = LIST_INDEX;
                    ChkAddChangeOnLogin.Checked =true;
                    ChkAddEnabled.Checked =true; 
                    LoadDDLDefaults();             
                    BindData();
                    LoadUser();    
                }

                this.tsUserMaintenance.Attributes.Add("onclick","SetFocus();");

        }
Code:
private void BindData()
        {
            string userID=null;
            userID= GetObjectFromSession("UserId").ToString(); 
            DataSet    dsUserDetails = new DataSet();
            switch(GetObjectFromSession("UserRole").ToString().Trim())
            {
                case "SAdmin":
                {
                    dsUserDetails = m_User.GetSOUsers(userID,GetObjectFromSession("Agency").ToString());
                    cmbEditAgency.SelectedValue= GetObjectFromSession("Agency").ToString();    
                    cmbAddAgency.SelectedValue=GetObjectFromSession("Agency").ToString();    

                    cmbEditAgency.Enabled = false; 
                    cmbAddAgency.Enabled =false;


                    lblAgency.Visible =false;cmbAgency.Visible =false;
                    lblRole.Visible=false;cmbRole.Visible =false;
                    dgrUserList.PageSize=1000;
                    break;
                }
                case "Admin":
                {
                    if(bindflg==0)
                    {

                        cmbAgency.Items.Insert(0,"");cmbAgency.Items.Insert(1,"ALL");
                        cmbEditAgency.Items.Insert(0,"");
                        cmbAddAgency.Items.Insert(0,"");
                        cmbRole.Items.Insert(0,"ALL");
                        cmbRole.SelectedIndex =3;
                        cmbAgency.SelectedIndex=1;
                        cmbAddRoleCode.Items.Insert(0,"");
                        cmbEditRoleCode.Items.Insert(0,"");



                    }
                    dsUserDetails = m_User.GetUser(cmbAgency.SelectedValue.ToString(),cmbRole.SelectedValue.ToString());

                    break;
                }
            }
            dgrUserList.DataSource = dsUserDetails;
            DataView source = new DataView();

            dgrUserList.DataBind();            

            if(dgrUserList.Items.Count > 0)
            {
                dgrUserList.Visible =true;
                lblNoResultsFound.Visible = false;
            }
            else
            {
                dgrUserList.Visible = false;
                lblNoResultsFound.Visible = true;

            }
            if(dsUserDetails.Tables[0].Rows.Count <= dgrUserList.PageSize )
            {
                dgrUserList.PagerStyle.Visible=false;
            }
            else
            {
                dgrUserList.PagerStyle.Visible=true;
            } 
        }
Code:
 private void btnSaveUserDetails_Click(object sender, System.EventArgs e)
                    {

                bool result1  = ValidateControls();

                if(!result1)
                {
                           bool    result  = PopulateEditDataSet();

                        if(result)
                        {
                            m_User.UpdateUser(ud);
                            tsUserMaintenance.SelectedIndex = LIST_INDEX;
                            bindflg=1;
                            BindData(); 

                        }
                        else
                        {
                        errorControl.ShowMessageFromXml("DATASET_DOES_NOT_EXIST",CustomPageControls.DisplayMode.Warning);
                        }

                }
                else
                {    EditUsers.Enabled = true;
                    tsUserMaintenance.SelectedIndex = EDIT_INDEX;
                    if((cmbEditRoleCode.SelectedIndex==1)||(cmbEditRoleCode.SelectedIndex==2))
                    {
                        cmbEditAgency.Enabled=false;
                    }
                    else
                    {
                        cmbEditAgency.Enabled=true;
                    }
                }

                   }

loaduser() function loads the screen with data in edit mode.I have not posted the code for loaduser() function.Please help me to fix this problem.It is urgent .Thanks












Similar Threads
Thread Thread Starter Forum Replies Last Post
Rebinding a data to combo box zaki79 .NET Framework 1.x 2 April 25th, 2008 04:43 AM
Doing Chapter 6 from intial skeleton djung01 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 July 20th, 2007 11:26 AM
rebinding checkbox checks in a template column texasraven ASP.NET 1.x and 2.0 Application Design 4 October 22nd, 2006 06:16 PM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM
State of CheckBox in ItemTemplate of DataGrid bpgadhia Classic ASP Professional 1 August 19th, 2004 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.