Show content a specific data to another page in a gridview asp.net c #

0

I would like you to help me by doing a list in your GRIDVIEW but at the end there is a see, that is, when I select I want to to show each record on another page.

my code is this:

   protected void DtgGestiones_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (this.IsPostBack)
            {
                try
                {
                    DtTab = new DataTable();
                    DtTab = (DataTable)Session["Data"];
                    DtgGestiones.CurrentPageIndex = 0;
                    DtgGestiones.CurrentPageIndex = e.NewPageIndex;
                    DtgGestiones.DataSource = DtTab;
                    DtgGestiones.DataBind();

                    //LLenarGrilla();
                }
                catch (Exception Ex)
                {


                }
            }
        }

MY HTML CODE

<asp:DataGrid ID="DtgGestiones" runat="server" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false"
                        BorderWidth="1px" CellPadding="0" CellSpacing="0" Font-Bold="False" Font-Overline="False" Font-Strikeout="False"
                        HorizontalAlign="Left" PageSize="250" PagerStyle-Mode="NumericPages" HeaderStyle-Font-Bold="true"
                        CssClass="table table-hover table-bordered table-condensed table-striped"
                        Font-Names="Calibri" Font-Size="12px" OnItemCommand="DtgGestiones_ItemCommand" PagerStyle-CssClass="pagGrig" OnPageIndexChanged="DtgGestiones_PageIndexChanged" OnSortCommand="DtgGestiones_SortCommand" OnSelectedIndexChanged="DtgGestiones_SelectedIndexChanged">

                        <Columns> 
                            <asp:BoundColumn DataField="RUBRO" SortExpression="RUBRO" HeaderText="RUBRO" ReadOnly="True">

                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="OFICINA" SortExpression="OFICINA" HeaderText="OFICINA" ReadOnly="true"></asp:BoundColumn>
                            <asp:BoundColumn DataField="USUARIO ATENCION" SortExpression="USUARIO ATENCION" HeaderText="USUARIO ATENCION" ReadOnly="True"></asp:BoundColumn>
                            <asp:BoundColumn DataField="FECHA DE EMISION"  SortExpression="FECHA DE EMISION" HeaderText="FECHA DE EMISION" ReadOnly="True" DataFormatString="{0:dd/MM/yyyy}"></asp:BoundColumn>
                            <asp:BoundColumn DataField="FECHA DE VENCIMIENTO" SortExpression="FECHA DE VENCIMIENTO" HeaderText="FECHA DE VENCIMIENTO" ReadOnly="True" DataFormatString="{0:dd/MM/yyyy}">
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="MONTO PAGADO" SortExpression="MONTO PAGADO" HeaderText="MONTO PAGADO" ReadOnly="True" DataFormatString="{0:0,0.00}">
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="NUMERO DE RECIBO" SortExpression="NUMERO DE RECIBO" HeaderText="NUMERO DE RECIBO" ReadOnly="True" >
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="PAGADO" SortExpression="PAGADO" HeaderText="PAGADO" ReadOnly="True" >
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:BoundColumn>
                            <asp:BoundColumn DataField="VALIDADO" HeaderText="VALIDADO" ReadOnly="True" sortExpression="VALIDADO" >
                                <ItemStyle HorizontalAlign="Right" />
                            </asp:BoundColumn>
                            <asp:ButtonColumn CommandName="Gestiones" HeaderText="Gestionar" Text="Ver" >
                                <ItemStyle
                                    Font-Bold="False" Font-Italic="False" Font-Overline="False"
                                    Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" />
                            </asp:ButtonColumn>
                        </Columns>
                    </asp:DataGrid>

    
asked by PieroDev 30.03.2017 в 22:37
source

1 answer

0
Solucion era agregar una propiedad al gridview :


protected void DtgGestiones_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Gestiones")
            {
                try
                {
                    DtSet = new DataSet();
                    SqlConnection con = new SqlConnection(ObtenerCadenaConexion());
                    con.Open();

                    SqlCommand cmd = new SqlCommand("SP_BuscarSeguimiento", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter p1 = new SqlParameter("OPT", 2);
                    SqlParameter p2 = new SqlParameter("periodo", "");
                    SqlParameter p3 = new SqlParameter("oficina", "");
                    SqlParameter p4 = new SqlParameter("rubro", e.Item.Cells[1].Text);

                    cmd.Parameters.Add(p1);
                    cmd.Parameters.Add(p2);
                    cmd.Parameters.Add(p3);
                    cmd.Parameters.Add(p4);



                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    DtgVerGestiones.DataSource = dt;
                    DtgVerGestiones.Visible = true;
                    DtgVerGestiones.DataBind();

                    con.Close();





                }
                catch (Exception Ex)
                {
                    // DvError.Visible = true;
                    Session["13"] = Ex.Message;
                }
            }
        }
    
answered by 30.03.2017 в 23:29