none
Tengo problemas para cargar un DetailsView a partir de un gridview RRS feed

  • Pregunta

  • Hola amigos, mi problema es el siguiente.

    Quiero que al querer dar click en el botón seleccionar de mi Gridview, aparezca un DetailsView con más detalles de ese fila.

    Este es mi código ASP.NET

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:GridView ID="GridView1" DataKeyNames="s_num_folio_vale" OnRowCommand="GridView1_RowCommand" runat="server" AutoGenerateColumns="false" EmptyDataText="No hay datos que mostrar">
                    <Columns>
    
    
                        <asp:ButtonField CommandName="detalle" Text="Seleccionar" HeaderText="VISTA DETALLE" ButtonType="Button">
                            <ControlStyle CssClass="btn btn-default"></ControlStyle>
                        </asp:ButtonField>
                        <asp:BoundField DataField="s_num_folio_vale" HeaderText="NUM. FOLIO VALE" />
                        <asp:BoundField DataField="i_idficha_responsable" HeaderText="USUARIO FICHA RESP." />
                        <asp:BoundField DataField="s_nombre" HeaderText="NOMBRE USUARIO" />
                        <asp:BoundField DataField="s_a_paterno" HeaderText="APELLIDO P. USUARIO" />
                        <asp:BoundField DataField="s_a_materno" HeaderText="APELLIDO M. USUARIO" />
                        <asp:BoundField DataField="Expr9" HeaderText="CARGO USUARIO" />
                        <asp:BoundField DataField="s_desc_marca" HeaderText="MARCA" />
                        <asp:BoundField DataField="s_modelo" HeaderText="MODELO" />
                        <asp:BoundField DataField="s_num_serie" HeaderText="NUM. SERIE" />
    
                    </Columns>
    
                </asp:GridView>
    
            </ContentTemplate>
        </asp:UpdatePanel>
    
        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
    
                <img alt="Cargando, espere por favor..." src="" />
            </ProgressTemplate>
    
        </asp:UpdateProgress>
    
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                    </div>
                    <div class="modal-body">
                        <asp:DetailsView ID="DetailsView1" DataKeyNames="s_num_folio_vale" CssClass="footable" runat="server" Height="50px" Width="125px" AutoGenerateRows="False">
                            <Fields>
                                <asp:BoundField DataField="s_num_folio_vale" HeaderText="NUM. FOLIO VALE"></asp:BoundField>
                                <asp:BoundField DataField="fecha_creacion" HeaderText="FECHA"></asp:BoundField>
                                <asp:BoundField DataField="f_costo" HeaderText="COSTO"></asp:BoundField>
                                <asp:BoundField DataField="s_desc_accesorio" HeaderText="ACCESORIOS"></asp:BoundField>
                                <asp:BoundField DataField="s_desc_linea" HeaderText="TIPO LINEA"></asp:BoundField>
                                <asp:BoundField DataField="ubicacion" HeaderText="UBICACION"></asp:BoundField>
                                <asp:BoundField DataField="i_clv_centrot" HeaderText="CLAVE CENTRO TRABAJO"></asp:BoundField>
                                <asp:BoundField DataField="i_clv_depto" HeaderText="CLAVE DEPARTAMENTO"></asp:BoundField>
                                <asp:BoundField DataField="s_desc_depto" HeaderText="NOMBRE DEPTO."></asp:BoundField>
                                <asp:BoundField DataField="i_ficha_instala" HeaderText="FICHA INSTALA"></asp:BoundField>
                                <asp:BoundField DataField="s_nombre" HeaderText="NOMBRE"></asp:BoundField>
                                <asp:BoundField DataField="s_a_paterno" HeaderText="APELLIDO PATERNO"></asp:BoundField>
                                <asp:BoundField DataField="s_a_materno" HeaderText="APELLIDO MATERNO"></asp:BoundField>
                                <asp:BoundField DataField="i_ficha_autoriza" HeaderText="FICHA AUTORIZA"></asp:BoundField>
                                <asp:BoundField DataField="Expr1" HeaderText="NOMBRE"></asp:BoundField>
                                <asp:BoundField DataField="Expr2" HeaderText="APELLIDO PATERNO"></asp:BoundField>
                                <asp:BoundField DataField="Expr3" HeaderText="APELLIDO MATERNO"></asp:BoundField>
                            </Fields>
                        </asp:DetailsView>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
    
                    </div>
                </div>
            </div>
        </div>
    </asp:Content>

    Y mi código aspx.vb:

    Partial Class Default3
        Inherits System.Web.UI.Page
        Dim cn As New SqlConnection("Data Source=DESKTOP-4VQQN6E;Initial Catalog="";Persist Security Info=True;User ID=sa;Password=""")
    
        Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            If Not IsPostBack Then
                CargarGrid()
            End If
        End Sub
    
        Protected Sub CargarGrid()
            Dim cmd As New SqlCommand("BindHistorialVale", cn)
            cmd.CommandType = CommandType.StoredProcedure
            cn.Open()
            Dim adp As New SqlDataAdapter(cmd)
            Dim table As New DataTable
            adp.Fill(table)
            GridView1.DataSource = table
            GridView1.AutoGenerateColumns = False
            GridView1.DataBind()
            cn.Close()
        End Sub
    
        Protected Sub CargarDetailsView(s_num_folio_vale As String)
            Dim cmd As New SqlCommand("BindDetailVale", cn)
            cmd.Parameters.AddWithValue("@s_num_folio_vale", s_num_folio_vale)
            cmd.CommandType = CommandType.StoredProcedure
    
            cn.Open()
            Dim adp As New SqlDataAdapter(cmd)
            Dim table As New DataTable
            adp.Fill(table)
            DetailsView1.DataSource = table.DefaultView
    
            DetailsView1.DataBind()
    
            cn.Close()
        End Sub
    
    
        Protected Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs)
            Dim s_num_folio_vale = GridView1.SelectedValue
            If e.CommandName.Equals("detalle") Then
                Dim sb As New System.Text.StringBuilder()
                sb.Append("<script type='text/javascript'>")
                sb.Append("$('#myModal').modal('show');")
                sb.Append("</script>")
                ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "ModalScript", sb.ToString(), False)
    
    
                CargarDetailsView(s_num_folio_vale)
            End If
        End Sub
    
    
    End Class

    El problema aparece cuando doy click en el botón Seleccionar aparece un error:

    Procedure or function 'BindDetailVale' expects parameter '@s_num_folio_vale', which was not supplied.

    martes, 3 de mayo de 2016 19:23