I have a Listbox
which I add items to it in the OnClick
event. I have this Listbox
inside a panel( Pnl_Pdfviewers
) and table
.
This panel is the pop up panel which is make it visible in the onclick
event
Onclickevent
{
//Call method to fill list box
ModalPopupExtender2.Show();
}
// Fill list box
reader = server.ExecuteReader(CommandType.Text, usernameQuery, paramete);
while (reader.Read())
{
lst_PdfViewers.Items.Add(reader["Name"].ToString());
}
reader.Close();
everything is fine, but the listbox
is always empty. I read the value from the table
and add that to the listbox
. Why is the listbox
empty always?
<asp:ModalPopupExtender ID="ModalPopupExtender2" BackgroundCssClass="modalBackground" TargetControlID="btnShowPopup2" CancelControlID="btn_PdfCancel" PopupControlID="Pnl_Pdfviewers" runat="server"> </asp:ModalPopupExtender>
<asp:Panel ID="Pnl_Pdfviewers" runat="server" BackColor="White" Height="250px" Width="350px" Style="display: none">
<table>
<tr>
<td align="center">
<asp:ListBox ID="lst_PdfViewers" runat="server" ></asp:ListBox>
</td>
</tr>
</table>
</asp:Panel>
UPDATE:
DataSet ds = new DataSet();
ds = server.ExecuteQuery(CommandType.Text, usernameQuery, paramete);
lst_PdfViewers.DataSource = ds;
lst_PdfViewers.DataBind();
Databinding is done successfully but it is not displaying inside the modal pop up extender
I ll suggest wrapping your Listbox
with an UpdatePanel
and calling myUpdatePanel.Update();
after
lst_PdfViewers.DataBind();
It works for us in similar cases. Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.