Ver Mensaje Individual
  #9 (permalink)  
Antiguo 11/11/2011, 09:24
Avatar de stuart_david3
stuart_david3
 
Fecha de Ingreso: agosto-2011
Mensajes: 215
Antigüedad: 12 años, 7 meses
Puntos: 1
Respuesta: Abrir nueva págna con un DataGrid

Muchísimas gracias AWesker Disculpa por tardar tanto en contestarte. Bueno, eh tenido detalles con el TemplateField, me dice que: El tipo 'System.Web.UI.WebControls.GridView' no tiene ninguna propiedad pública cuyo nombre sea 'TemplateField'.

Lo puse dentro del GridView como me dijiste:

Código ASP:
Ver original
  1. <asp:gridview id="CustomersGridView"
  2.        datasourceid="CustomersSource"
  3.        autogeneratecolumns="False"
  4.        autogenerateselectbutton="True"
  5.        allowpaging="True"
  6.        selectedindex="1"
  7.        onselectedindexchanged="CustomersGridView_SelectedIndexChanged"
  8.        onselectedindexchanging="CustomersGridView_SelectedIndexChanging"  
  9.        runat="server" DataKeyNames="rpe" BackColor="LightGoldenrodYellow"
  10.          BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black"
  11.          GridLines="None">
  12.       <asp:TemplateField HeaderText="Detalle" ItemStyle-Width="70px" HeaderStyle-Width="70px">
  13.       <ItemTemplate>
  14.        <asp:LinkButton ID="Lnk_Redireccionar" Style="background-color: Transparent; margin-top: -3px;"
  15.         CommandName="Detalle" runat="server" CommandArgument='<%#Eval("rpe") %>'>
  16.         </asp:LinkButton>
  17.       </ItemTemplate>
  18.       <HeaderStyle Width="70px" />
  19.       <ItemStyle HorizontalAlign="Center" />
  20.      </asp:TemplateField>
  21.          <AlternatingRowStyle BackColor="PaleGoldenrod" />
  22.  
  23.          <Columns>
  24.              <asp:BoundField DataField="rpe"
  25.                  HeaderText="RPE del Empleado"
  26.                  InsertVisible="False" ReadOnly="True"

Y en el evento de mi SelectedIndex el if para el CommandName:

Código ASP:
Ver original
  1. Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
  2.  
  3.     Dim row As GridViewRow = CustomersGridView.SelectedRow
  4.  
  5.         Dim cadena As String = row.Cells(1).Text
  6.         Dim MyConnection As SqlConnection = New SqlConnection("server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no")
  7.         Dim MyCommand As SqlCommand = New SqlCommand("SELECT rpe as RPE_del_Empleado, convert(varchar,fe_inic,103) as Fecha_de_la_Incidencia, cl_incid AS Tipo_de_Incidencia FROM b_asiste WHERE (cl_incid='026' OR cl_incid='0670' OR cl_incid='050') AND rpe='" & cadena & "' GROUP BY rpe, cl_incid, fe_inic", MyConnection)
  8.         MyConnection.Open()
  9.  
  10.         Dim dr As SqlDataReader = MyCommand.ExecuteReader()
  11.         MyDataGrid.DataSource = dr
  12.         MyDataGrid.DataBind()
  13.         If (e.CommandName = "Detalle") Then
  14.             Response.Redirect("Default5.aspx?rpe=" + e.CommandArgument.ToString())
  15.         End If
  16.     End Sub

Pero me arroja el siguiente error:

'CommandName' no es un miembro de 'System.EventArgs'. :s