Foros del Web » Programación para mayores de 30 ;) » .NET »

Rotar GridView

Estas en el tema de Rotar GridView en el foro de .NET en Foros del Web. Estoy como loco intentando girar un GridView y no soy capaz. Tengo un GridView (con c#) y quiero que los campos me aparezcan en vertical. ...
  #1 (permalink)  
Antiguo 22/02/2008, 04:54
Avatar de kastesponja  
Fecha de Ingreso: febrero-2008
Mensajes: 12
Antigüedad: 16 años, 2 meses
Puntos: 0
Rotar GridView

Estoy como loco intentando girar un GridView y no soy capaz. Tengo un GridView (con c#) y quiero que los campos me aparezcan en vertical. no en horizontal. Si alguien sabe como hacerlo me salvaria la vida. PLEEEEEEEEEEEASE
  #2 (permalink)  
Antiguo 22/02/2008, 17:41
 
Fecha de Ingreso: enero-2008
Mensajes: 65
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: Rotar GridView

Montate un dataset tal como quieres, no??

Última edición por tunait; 26/02/2008 a las 02:36 Razón: remover firma
  #3 (permalink)  
Antiguo 25/02/2008, 03:05
Avatar de kastesponja  
Fecha de Ingreso: febrero-2008
Mensajes: 12
Antigüedad: 16 años, 2 meses
Puntos: 0
Re: Rotar GridView

Y como puedo montar el DataSet en vertical???
  #4 (permalink)  
Antiguo 25/02/2008, 06:58
Avatar de huenupan  
Fecha de Ingreso: noviembre-2007
Ubicación: Temuco - Chile
Mensajes: 48
Antigüedad: 16 años, 5 meses
Puntos: 3
Re: Rotar GridView

¿tablas cruzadas? nunca me resultó
  #5 (permalink)  
Antiguo 25/02/2008, 07:33
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 8 meses
Puntos: 87
Re: Rotar GridView

Lo unico q se me ocurre es hacer el override al evento OnPaint en Windows

y definir la forma de dibujarlo ahi.

saludos
peter
  #6 (permalink)  
Antiguo 25/02/2008, 17:08
 
Fecha de Ingreso: enero-2008
Mensajes: 65
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: Rotar GridView

Te lo pongo en pseudocodigo, pero seria algo así:

Dim dsNew as dataset

For i =0 to dsOld.row.count -1
For j=0 to dsOld.row(i).items.count -1
dsNew(i,j)=dsOld(j,i)
next
next

Última edición por tunait; 26/02/2008 a las 02:34 Razón: remover firma
  #7 (permalink)  
Antiguo 27/02/2008, 03:11
Avatar de kastesponja  
Fecha de Ingreso: febrero-2008
Mensajes: 12
Antigüedad: 16 años, 2 meses
Puntos: 0
Re: Rotar GridView

Lo quiero hacer en c#, no en Vb (lamento no haberlo indicado, culpa mia). Muchas gracias por responder pero ya tengo la solucion. No hace falta ni codigo ni nada. Un GridView es horizontal, pero el control DetailsView es exactamente igual, pero en vertical. Usando vs2005 lo unico que hay que hacer es usar ese control en lugar de el otro. Gracias por vuestras respuestas.
  #8 (permalink)  
Antiguo 30/04/2009, 10:39
 
Fecha de Ingreso: septiembre-2006
Ubicación: Buenos Aires
Mensajes: 132
Antigüedad: 17 años, 7 meses
Puntos: 0
Respuesta: Rotar GridView

Me tomo el atrevimiento de responder luego de un año este post porque la solucion concreta no la he encontrado en este foro y es bueno que la tengamos

Código:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FlipGridView.aspx.cs" Inherits="XmlPostData" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
      <div>
          <asp:GridView ID="GridView1" runat="server" ShowHeader="false" AllowSorting="true">
          </asp:GridView>
      </div>
  </form>
</body>
</html>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.IO;

public partial class FlipGridView:System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
   
        GridView1.DataSource = FlipDataSet(c());
        GridView1.DataBind();

    }

    public DataSet c()
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable("Company");
        DataRow dr;
        dt.Columns.Add(new DataColumn("accountNo", typeof(Int32)));
        dt.Columns.Add(new DataColumn("CompanyName", typeof(string)));
        dt.Columns.Add(new DataColumn("Address", typeof(string)));
        for (int i = 0; i <= 10; i++)
        {
            dr = dt.NewRow();
            dr[0] = i;
            dr[1] = "Company" + i + Environment.NewLine + "Title" + i;
            dr[2] = "Address" + i + Environment.NewLine + "Title" + i;
            dt.Rows.Add(dr);
        }
        ds.Tables.Add(dt);
        return ds;
    }
    public DataSet FlipDataSet(DataSet my_DataSet)
    {
        DataSet ds = new DataSet();
        foreach (DataTable dt in my_DataSet.Tables)
        {
            DataTable table = new DataTable();
            for (int i = 0; i <= dt.Rows.Count; i++)
            {
                table.Columns.Add(Convert.ToString(i));
            }
            DataRow r = null;
            for (int k = 0; k < dt.Columns.Count; k++)
            {
                r = table.NewRow();
                r[0] = dt.Columns[k].ToString();
                for (int j = 1; j <= dt.Rows.Count; j++)
                    r[j] = dt.Rows[j - 1][k];
                table.Rows.Add(r);
            }
            ds.Tables.Add(table);
        }

        return ds;
    }
}
te lo dejo en Visual Basic tambien


Código:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FlipGridView.aspx.cs" Inherits="XmlPostData" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
      <div>
          <asp:GridView ID="GridView1" runat="server" ShowHeader="false" AllowSorting="true">
          </asp:GridView>
      </div>
  </form>
</body>
</html>

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Net
Imports System.Text
Imports System.IO
Public Class FlipGridView
    Inherits System.Web.UI.Page
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        GridView1.DataSource = FlipDataSet(c)
        GridView1.DataBind
    End Sub
    
    Public Function c() As DataSet
        Dim ds As DataSet = New DataSet
        Dim dt As DataTable = New DataTable("Company")
        Dim dr As DataRow
        dt.Columns.Add(New DataColumn("accountNo", GetType(Int32)))
        dt.Columns.Add(New DataColumn("CompanyName", GetType(System.String)))
        dt.Columns.Add(New DataColumn("Address", GetType(System.String)))
        Dim i As Integer = 0
        Do While (i <= 10)
            dr = dt.NewRow
            dr(0) = i
            dr(1) = ("Company"  _
                        + (i  _
                        + (Environment.NewLine + ("Title" + i))))
            dr(2) = ("Address"  _
                        + (i  _
                        + (Environment.NewLine + ("Title" + i))))
            dt.Rows.Add(dr)
            i = (i + 1)
        Loop
        ds.Tables.Add(dt)
        Return ds
    End Function
    
    Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
        Dim ds As DataSet = New DataSet
        For Each dt As DataTable In my_DataSet.Tables
            Dim table As DataTable = New DataTable
            Dim i As Integer = 0
            Do While (i <= dt.Rows.Count)
                table.Columns.Add(Convert.ToString(i))
                i = (i + 1)
            Loop
            Dim r As DataRow = Nothing
            Dim k As Integer = 0
            Do While (k < dt.Columns.Count)
                r = table.NewRow
                r(0) = dt.Columns(k).ToString
                Dim j As Integer = 1
                Do While (j <= dt.Rows.Count)
                    r(j) = dt.Rows((j - 1))(k)
                    j = (j + 1)
                Loop
                table.Rows.Add(r)
                k = (k + 1)
            Loop
            ds.Tables.Add(table)
        Next
        Return ds
    End Function
End Class
  #9 (permalink)  
Antiguo 06/02/2010, 13:57
Avatar de Nachzeher  
Fecha de Ingreso: enero-2003
Mensajes: 249
Antigüedad: 21 años, 3 meses
Puntos: 1
Respuesta: Rotar GridView

Gracias..

Es lo que estaba buscando..
Hace 10 minutos me encargaron hacer algo parecido..



Gracias, de verdad!
  #10 (permalink)  
Antiguo 19/07/2010, 11:31
 
Fecha de Ingreso: marzo-2008
Mensajes: 286
Antigüedad: 16 años, 1 mes
Puntos: 1
Respuesta: Rotar GridView

hola que tal yo tengo la misma duda .... me gustaria hacer tablas cruzadas de articulos x almacen y en el medio que esten los montos segun la combinacion de estas 2


como se ha creado ese datatable("company")

en mi caso yo llamo a un select num_stoc,cod_articulo,cod_almacen from stock_almacen

esos son los campos que uso ... y quiero combinar

articulo x almacen

x favor ayuda que es urgentisimo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:52.