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

como agregar fila a un datagrid con informacion que esta guardado en otro dataset

Estas en el tema de como agregar fila a un datagrid con informacion que esta guardado en otro dataset en el foro de .NET en Foros del Web. Hola, tengo una tabla formada por un datagrid, y necesito colocar en la ultima fila de la tabla, los subtotales de cda columna, estos subtotales ...
  #1 (permalink)  
Antiguo 08/11/2004, 15:22
 
Fecha de Ingreso: diciembre-2003
Mensajes: 212
Antigüedad: 20 años, 5 meses
Puntos: 0
como agregar fila a un datagrid con informacion que esta guardado en otro dataset

Hola, tengo una tabla formada por un datagrid, y necesito colocar en la ultima fila de la tabla, los subtotales de cda columna, estos subtotales los estoy calculando asi:

strSql = " SELECT SUM(apto)AS TotalApto, SUM(avaluo_local)AS TotalLocal, SUM(oficina)AS TotalOficina, SUM(terreno)AS TotalTerreno,"
strSql = strSql & " SUM(casa_m)AS TotalCasaM, SUM(casa_c)AS TotalCasaC, SUM(edif_m)AS TotalEdifM, SUM(edif_c)AS TotalEdifC, "
strSql = strSql & " SUM(galpon_m)AS TotalGalponM, SUM(galpon_c)AS TotalGalponC, SUM(estac)AS TotalEstac, SUM(totalxAvaluador)AS TotalTotal"
strSql = strSql & " FROM AiMatriz_Avaluo_Temp"

daCommand = New SqlClient.SqlDataAdapter(strSql, Conn)
dsGeneral = New DataSet
daCommand.Fill(dsGeneral, "TotalAvaluosTipoInm")

como puedo agregar estos campos en la ultima fila del datagrid si este ha sido llenado con otro dataset?

Espero me puedan dar otra idea de como hacer esto, si lo que intento hacer es muy complicado, como puedo sumar todos los valores de una columna y mostrarlo en la ultima fila?

Última edición por sofia2; 08/11/2004 a las 15:24
  #2 (permalink)  
Antiguo 08/11/2004, 18:01
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Aqui está lo que buscas.

http://aspnet.4guysfromrolla.com/articles/020503-1.aspx

Salu2
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #3 (permalink)  
Antiguo 09/11/2004, 09:11
 
Fecha de Ingreso: diciembre-2003
Mensajes: 212
Antigüedad: 20 años, 5 meses
Puntos: 0
Gracias Rootk, use el codigo de la pagina que diste, lo adapte a lo que necesitaba y me funciono perfecto!!!
Una pequeña duda, quiero darle formato al total que se muestra en el footer del datagrid, y lo estoy haciendo asi:
e.Item.Cells(0).Font.Name = "Verdana"
e.Item.Cells(0).Font.Bold = True
pero no se como colocar el formato para cambiarle el tamaño a las letras, lo intente hacer asi pero me da error:
e.Item.Cells(0).Font.Size ="2"
como podria cambiarle el tamaño al total???
  #4 (permalink)  
Antiguo 09/11/2004, 09:26
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Para que no te metas en problemas simplemente puedes hacerlo así:


Cita:
e.Item.Cells(0).Text = "<font size='2' face='Verdana'><b>" & Total & "</b></font>"
Salu2
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #5 (permalink)  
Antiguo 09/11/2004, 11:41
 
Fecha de Ingreso: diciembre-2003
Mensajes: 212
Antigüedad: 20 años, 5 meses
Puntos: 0
ok, gracias!!
  #6 (permalink)  
Antiguo 10/11/2004, 09:55
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 19 años, 7 meses
Puntos: 0
alguien me peude ayudar para entregar las filas y sus detalles intermedios

miren mi post aqui Splinter algo me ayudo pero necesito mas ayuda porfa

http://forosdelweb.com/showthread.php?t=245674

mi problema es mostrar las filas intermedias
  #7 (permalink)  
Antiguo 10/11/2004, 18:07
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 19 años, 7 meses
Puntos: 0
hola

existe la propiedad viewCount
existe algo para sacar elporcentaje de una columna siguiendo con el ejemplo de rootk
  #8 (permalink)  
Antiguo 10/11/2004, 18:18
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 19 años, 7 meses
Puntos: 0
quiero que salga el porcentaje del total de la columna donde dice total

quiro que salga el porcentaje como se peude hacer
  #9 (permalink)  
Antiguo 11/11/2004, 06:24
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 19 años, 7 meses
Puntos: 0
porfaaaaaa alguien que me ayude a crar el procentaje al lado del totallll
  #10 (permalink)  
Antiguo 11/11/2004, 09:26
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 19 años, 7 meses
Puntos: 0
****PARA TODOS QUIENES DEBEN HACER LOS TOTALES INTERMEDIOS AQUI VA EL CODIGO REWENO



<%@ Page Language="vb" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SQLClient" %>
<script runat="server">

'----- DECLARA LOS SUMADORES DE TOTALES------
Dim viewCountSum as Integer = 0
Dim viewCountSum2 as Integer = 0
Dim viewCountSum3 as Integer = 0
Dim viewCountSum4 as Integer = 0
Dim viewCountSum5 as Integer = 0
Dim viewCountSum6 as Integer = 0
Dim viewCountSum7 as Integer = 0


Sub Page_Load(sender as Object, e as EventArgs)
BindData()
End Sub


Sub BindData()
'1. Create a connection
' Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
Dim MyConnection = New SqlConnection("Persist Security Info=False;User ID=docsadm;pwd=docsadm;Initial Catalog=SBIFBBVA;Data Source=TESTEDMS;Packet Size=4096;Workstation ID=ISRV_EDMS")

'2. Create the command object, passing in the SQL string

Const strSQL as String = "spx"
Dim myCommand as New SqlCommand(strSQL, myConnection)

'Set the datagrid's datasource to the datareader and databind

myConnection.Open()
dgPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)
dgPopularFAQs.DataBind()

End Sub


Sub ComputeSum(sender As Object, e As DataGridItemEventArgs)
'--------------------------------------SUMA TOTALES RECIBIDOS ----------------
'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "total"))
viewCountSum += viewCount

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(6).Text = "Total: " & String.Format("{0:#,###}", viewCountSum)
End If

'-------------------SUMA PORCENTAJES--------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount2 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "porcentaje"))
viewCountSum2 += viewCount2

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(7).Text = "Total: " & String.Format("{0:#,###}", viewCountSum2)
End If


'-------------------SUMA cOLUMNA EN PROCESO--------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount3 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ENPROCESO"))
viewCountSum3 += viewCount3

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(2).Text = "Total: " & String.Format("{0:#,###}", viewCountSum3)
End If


'-------------------SUMA cOLUMNA ATRASADO-------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount4 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ATRASADO"))
viewCountSum4 += viewCount4

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(3).Text = "Total: " & String.Format("{0:#,###}", viewCountSum4)
End If
'-------------------SUMA cOLUMNA CERRADO--------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount5 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "CERRADO"))
viewCountSum5 += viewCount5

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(4).Text = "Total: " & String.Format("{0:#,###}", viewCountSum5)
End If



'-------------------SUMA cOLUMNA CERRADO ATRASADO-------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount6 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "CERRADOATRASADO"))
viewCountSum6 += viewCount6

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(5).Text = "Total: " & String.Format("{0:#,###}", viewCountSum6)
End If



'-------------------SUMA cOLUMNA RE-ABIERTOS-------------------------------------------------------

'First, make sure we are dealing with an Item or AlternatingItem
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Snip out the ViewCount
Dim viewCount7 as Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "REABIERTO"))
viewCountSum7 += viewCount7

ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(8).Text = "Total: " & String.Format("{0:#,###}", viewCountSum7)
End If


'-----------------------------------------------------------------------------------

end sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="dgPopularFAQs" runat="server" AutoGenerateColumns="False" Font-Name="Verdana" Width="85%" Font-Size="11pt" HorizontalAlign="Center" ShowFooter="True" OnItemDataBound="ComputeSum">
<HeaderStyle backcolor="Navy" forecolor="White" horizontalalign="Center" font-size="14pt" font-bold="True" />
<FooterStyle backcolor="Navy" forecolor="White" font-size="12pt" font-bold="True" horizontalalign="Right" />
<Columns>
<asp:BoundColumn DataField="tema2_email" HeaderText="TEMA2 EMAIL" />
<asp:BoundColumn DataField="tipo_email" HeaderText="TIPO EMAIL" />
<asp:BoundColumn DataField="ENPROCESO" HeaderText="PROCESO" />
<asp:BoundColumn DataField="ATRASADO" HeaderText="ATRASADO" />
<asp:BoundColumn DataField="CERRADO" HeaderText="CERRADO" />
<asp:BoundColumn DataField="CERRADOaTRASADO" HeaderText="CERRADO ATRASADO" />
<asp:BoundColumn DataField="total" HeaderText="TOTALES" DataFormatString="{0:#,###}" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="15%" />
<asp:BoundColumn DataField="porcentaje" HeaderText="Porcentaje" />
<asp:BoundColumn DataField="ReAbierto" HeaderText="Reabierto" />
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
  #11 (permalink)  
Antiguo 15/03/2005, 03:06
Avatar de univercity  
Fecha de Ingreso: noviembre-2002
Mensajes: 681
Antigüedad: 21 años, 5 meses
Puntos: 0
me queme los ojos buscando soluciones para mi problema y aqui estaba, espero funcione lo voy a probar...

Slds.
__________________
"Lo importante es nunca dejar de hacerse preguntas"
Albert Einstein
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 04:49.