Hi All,
Have landed into a scenario, experts might be able to assist me.
Have an aspx page which is composed of various user controls.
In one of the user controls, I have added a dropdownlist and few images.
On click of one of the images, another aspx page opens up as a popup. Some operations happen there and on the OK button click of the popup page, a name has to be saved in the DB. At the same time the dropdownlist present in the user control has to be populated with the same name. Saving, retrieval from the DB, all are happening quite fine. But the dropdownlist is not populating. I googled and found out that if I place my dropdownlist inside an Update Panel and on a hidden button click, If I try to populate the dropdownlist, it will be.Have tried all these stuffs, but it just doesn't happen.
Below are my codes. Please have a look and try to assist.
Code for dropdownlist in the user control:
<asp:UpdatePanel ID="customUpdatePanel" runat="server">
<ContentTemplate>
<asp:DropDownList ID="dropDownListView" runat="server">
<asp:ListItem Value="0" Text="Standard"></asp:ListItem>
</asp:DropDownList>
<input type="button" ID="Button1" runat="server" value="" style="display:block" onserverclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:ImageButton ID="btnNew" runat="server" Height="20px" ImageUrl="~/Images/new.png" Width="20px" OnClientClick="ShowPopup();" />
function ShowPopup() {
var returnValue = window.open("ViewColumnOptions.aspx", "ViewColumnOptions", "height=400,width=600");
if (returnValue==true) {
document.getElementById("Button1").click();
}
}
OK button click code of the popup page:
protected void btnOK_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtViewName.Text))
{
obj.SaveReportViewToDataBase(saveObj);
Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "Close();", true);
}
}
function Close() {
window.returnValue = true;
window.close();
Methods in usercontrol.ascx.cs:
public void Button1_Click(object sender, EventArgs s)
{
PopulateOtherViews();
}
public void PopulateOtherViews()
{
SaveReportViewFilter<ReportFilterBase> newObj = new SaveReportViewFilter<ReportFilterBase>();
ViewColumnOptions vwobj = new ViewColumnOptions();
newObj.UserName = vwobj.Page.User.Identity.Name;
SaveReportView<ReportFilterBase> obj2 = new SaveReportView<ReportFilterBase>();
DataTable dt = obj2.GetSaveReportViewFromDataBase(newObj);
dropDownListView.DataSource = dt;
dropDownListView.DataTextField = dt.Columns[0].ToString();
dropDownListView.DataValueField = dt.Columns[0].ToString();
dropDownListView.DataBind();
}
Everything seems allright..but the dropdownlist just doesn't populate.
Experts please help or provide some pointers.
Regards
Anurag