gridview inside jquery ui Dialog

寵の児 提交于 2019-12-10 11:44:34

问题


I managed to get my jquery ui Dialog working from codebehind. Now i face another problem.
I have a gridview inside the div that's being used to .dialog(). That gridview is not showing inside the dialog.
If i enter another control as an asp:button it does shows, so i'm a little confused. For example:

<div id="DivMostrarIguales" title="Número Único Igual">
            <asp:Button ID="Hello" runat="server" Text="Hello" />
            <asp:GridView ID="gvMostrarIgualesEntrante" ...

In that case the dialog loads and has the button visible, but not the gridview.

I call MostrarVentanaMostrarVentanaIgualesEntrante from this button:

<asp:Button ID="btMostrarIgualesEntrante" runat="server" Text="Revisar si ya existe"
                                                    OnClick="MostrarVentanaIgualesEntrante" ValidationGroup="none" CausesValidation="false"
                                                    CssClass="Button" />

Everything is inside an updatepanel.

I checked the datatable wich is used to bind the data and it contains one row so the gridview does have data.

Can anyone help me please?
Thank you.

My code:

<div id="DivMostrarIguales" title="Número Único Igual">
            <asp:GridView ID="gvMostrarIgualesEntrante" runat="server" AutoGenerateColumns="false"
                EmptyDataText="No se encontraron documentos." PageSize="10" AllowPaging="true"
                DataKeyNames="DocumentoEntranteID" Visible="true" CssClass="tablaGrid">
                <Columns>
                    <asp:CommandField ButtonType="Image" SelectImageUrl="/images/UncheckedRadio.gif"
                        ShowSelectButton="True" />
                    <asp:BoundField DataField="DocumentoEntranteID" HeaderText="ID" SortExpression="DocumentoEntranteID"
                        ItemStyle-HorizontalAlign="Center" ItemStyle-Width="30px"></asp:BoundField>
                    <asp:BoundField DataField="FechaIngreso" HeaderText="Ingreso" SortExpression="FechaIngreso"
                        ItemStyle-HorizontalAlign="Center" DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="false"
                        ItemStyle-Width="130px"></asp:BoundField>
                    <asp:BoundField DataField="FuncionarioRecibe" HeaderText="Recibe" SortExpression="FuncionarioRecibe"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="NumeroOficio" HeaderText="Número Oficio" SortExpression="NumeroOficio"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="NumeroUnico" HeaderText="Número único" SortExpression="NumeroUnico"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="Remitente" HeaderText="Remitente" SortExpression="Remitente"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="OficinaRemitente" HeaderText="Oficina" SortExpression="OficinaRemitente"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="Dirigido" HeaderText="Dirigido" SortExpression="Dirigido"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="Asignado" HeaderText="Asignado" SortExpression="Asignado"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="OficinaArea" HeaderText="Oficina Recibe - Área" SortExpression="Area"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                    <asp:BoundField DataField="EstadoDocumento" HeaderText="Estado Documento" SortExpression="EstadoDocumento"
                        ItemStyle-HorizontalAlign="Left"></asp:BoundField>
                </Columns>
            </asp:GridView>
        </div>

My .CS:

private void CargarGridMostrarIgualesEntrante()
    {
        //revisar que el texto del textbox vaya con su formato correcto.
        if (Regex.IsMatch(tbNumeroUnico.Text, @"\d{2}-\d{6}-\d{4}-\w\w"))
        {
            lbNumeroUnicoEntrante.Visible = false;

            //cargar solo los documentos entrantes que tengan ese mismo número único.
            _documentosEntrantesNumeroUnicoIgual = _documentosHandler.ObtenerDocumentosEntrantesPorNumeroUnico(tbNumeroUnico.Text);

            if (_documentosEntrantesNumeroUnicoIgual.Count > 0)
            {
                DataTable table = new DataTable();
                table.Columns.Add(new DataColumn("DocumentoEntranteID", typeof (long)));
                table.Columns.Add(new DataColumn("FechaIngreso", typeof (DateTime)));
                table.Columns.Add(new DataColumn("FuncionarioRecibe", typeof (string)));
                table.Columns.Add(new DataColumn("NumeroOficio", typeof (string)));
                table.Columns.Add(new DataColumn("NumeroUnico", typeof (string)));
                table.Columns.Add(new DataColumn("Remitente", typeof (string)));
                table.Columns.Add(new DataColumn("OficinaRemitente", typeof (string)));
                table.Columns.Add(new DataColumn("Dirigido", typeof (string)));
                table.Columns.Add(new DataColumn("Asignado", typeof (string)));
                table.Columns.Add(new DataColumn("OficinaArea", typeof (string)));
                table.Columns.Add(new DataColumn("EstadoDocumento", typeof (string)));

                foreach (DocumentoEntrante documentoEntrante in _documentosEntrantesNumeroUnicoIgual)
                {
                    DataRow row = table.NewRow();
                    row["DocumentoEntranteID"] = documentoEntrante.DocumentoEntranteID;
                    row["FechaIngreso"] = documentoEntrante.FechaIngreso;
                    row["FuncionarioRecibe"] = documentoEntrante.FuncionarioRecibe.NombreFuncionario;
                    row["NumeroOficio"] = documentoEntrante.NumeroOficio;
                    row["NumeroUnico"] = documentoEntrante.NumeroUnico;
                    row["Remitente"] = documentoEntrante.Remitente;
                    row["OficinaRemitente"] = documentoEntrante.Oficina.Nombre;
                    row["Dirigido"] = documentoEntrante.FuncionarioDirigido.NombreFuncionario;
                    row["Asignado"] = documentoEntrante.FuncionarioAsignado.NombreFuncionario;
                    row["OficinaArea"] = documentoEntrante.Area.Oficina.Nombre + " - " +
                                         documentoEntrante.Area.Nombre;
                    row["EstadoDocumento"] = documentoEntrante.EstadoDocumento.Nombre;

                    table.Rows.Add(row);
                }

                gvMostrarIgualesEntrante.DataSource = table;
                gvMostrarIgualesEntrante.DataBind();
            }else
            {
                gvMostrarIgualesEntrante.DataSource = null;
                gvMostrarIgualesEntrante.EmptyDataText = "No existe un documento entrante con el mismo número único";
                gvMostrarIgualesEntrante.DataBind();

            }
            runjQueryCode("dlg = $('#DivMostrarIguales').dialog({autoOpen: false,show: 'fold',hide: 'clip',width: 1272,height: 211,close: function(ev, ui) { $('.ui-effects-wrapper').remove(); }}); $('#DivMostrarIguales').dialog('open')");
        }
        else
        {
            lbNumeroUnicoEntrante.Visible = true;
        }
    }

protected void MostrarVentanaIgualesEntrante(object sender, EventArgs e)
    {
        CargarGridMostrarIgualesEntrante();
    }

回答1:


I think that is because of the postback coming from within UpdatePanel and the reason could be stemming from what is mentioned here.

Good to know it worked for you.



来源:https://stackoverflow.com/questions/5464793/gridview-inside-jquery-ui-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!