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