Hi all,
I've been stuck on this error for a harrowing amount of time, so I thought I'd bring my lamentations here. I'll try here to provide as much information as possible.
I have two buttons with the following code in my ASP.NET page:
Now, the purpose of these buttons is to open up another .aspx page with a listbox that is databound to a datasource depending on the operation (the operations 'add' or 'remove' are passed as part of the query string).
When I click the add users button, everything works fine and the list gets populated as expected. However, if I click on the remove users button, the listbox does not populate.
I have two datasource controls on the page to which the buttons are redirecting the user (UserToGroupListDialog.aspx i.e.). Here is the code for what I'm doing on page load:
As you can see, I'm doing exactly the same thing with the listbox, except that I'm changing the datasource to which it is going to be bound. I have checked the queries that are configured to the datasource controls and they work as expected (they both run stored procedures to get the dataset that needs to be populated onto the listbox).
There is no problem with the query string either and the name-value pairs get passed on to the page as expected. I also tested whether the "remove" if condition is checked and entered into when the redirection happens, and it does.
So why isn't the remove users datasource control populating the listbox when the remove users button is pressed on the parent page? What am I missing here?
Appreciate your guidance on this as I cannot fathom what the source of the problem is.
Thank you. Will be glad to provide more information as necessary.
I've been stuck on this error for a harrowing amount of time, so I thought I'd bring my lamentations here. I'll try here to provide as much information as possible.
I have two buttons with the following code in my ASP.NET page:
Code:
protected void AddUsersBtn_Click(object sender, EventArgs e)
{
String opName = "add";
String grpId = GroupList.SelectedItem.ToString();
String url = "UserToGroupListDialog.aspx?Operation="+opName+"&SelectedGrp="+grpId;
String execScript = "callPopup('" + url + "');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addUsersToGrpsDialog", execScript, true);
}
protected void RemoveUsersBtn_Click(object sender, EventArgs e)
{
String opName = "remove";
String grpId = GroupList.SelectedItem.ToString();
String url = "UserToGroupListDialog.aspx?Operation="+opName+"&SelectedGrp="+grpId;
String execScript = "callPopup('" + url + "');";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "removeUsersFromGrpsDialog", execScript, true);
}
Now, the purpose of these buttons is to open up another .aspx page with a listbox that is databound to a datasource depending on the operation (the operations 'add' or 'remove' are passed as part of the query string).
When I click the add users button, everything works fine and the list gets populated as expected. However, if I click on the remove users button, the listbox does not populate.
I have two datasource controls on the page to which the buttons are redirecting the user (UserToGroupListDialog.aspx i.e.). Here is the code for what I'm doing on page load:
Code:
protected void Page_Load(object sender, EventArgs e)
{
String opName = Request.QueryString["Operation"];
if (!Page.IsPostBack)
{
Page.ClientScript.RegisterClientScriptInclude("functions", "js/showDialog.js");
if (opName.Equals("add"))
{
AvailUsersList.DataSourceID = "TXDatabaseAvailableUsersDataSource";
AvailUsersList.DataTextField = "UserName";
AvailUsersList.DataValueField = "UserName";
AvailUsersList.DataBind();
}
if (opName.Equals("remove"))
{
AvailUsersList.DataSourceID = "TXDatabaseRemoveAvailableUsersDataSource";
AvailUsersList.DataTextField = "UserName";
AvailUsersList.DataValueField = "UserName";
AvailUsersList.DataBind();
}
SelectedGrpLbl.Text = Request.QueryString["SelectedGrp"].ToString(); // set selected group
if (SelectedGrpLbl.Text == null || SelectedGrpLbl.Text == "")
SelectedGrpLbl.Text = "Error!";
CancelOperationBtn.Attributes.Add("onclick", "window.opener = self; window.close();");
}
}
As you can see, I'm doing exactly the same thing with the listbox, except that I'm changing the datasource to which it is going to be bound. I have checked the queries that are configured to the datasource controls and they work as expected (they both run stored procedures to get the dataset that needs to be populated onto the listbox).
There is no problem with the query string either and the name-value pairs get passed on to the page as expected. I also tested whether the "remove" if condition is checked and entered into when the redirection happens, and it does.
So why isn't the remove users datasource control populating the listbox when the remove users button is pressed on the parent page? What am I missing here?
Appreciate your guidance on this as I cannot fathom what the source of the problem is.
Thank you. Will be glad to provide more information as necessary.