Bienvenidos

Recuerda que tus comentarios son importantes y recuerda agradecer si te fue útil algun artículo publicado aquí.

L1f3 15 a D@nc3 Flo0r

sábado, 10 de mayo de 2008

CLAUSULA: CASE WHEN

CLAUSULA: CASE WHEN

Es parecida al CASE que utilizamos en programación, con la ventaja de que el mismo puede ser utilizado en un campo de la consulta.

Caso de uso: Imagine que tiene un campo dentro de la tabla en el que usted quiere desplegar un valor en específico en el caso en el que ese campo tenga valor (es decir no desea desplegar el valor del campo sino un valor especificado por usted). En ese caso utilizamos el CASE WHEN el campo en cuestión tenga valor le decimos que despliegue la letra "P" de lo contrario que despliegue un espacio.

Ej.:

SELECT [campo1], [campo2], CASE WHEN [campo3] IS NOT NULL THEN 'P' ELSE ' ' END
FROM [tabla]

miércoles, 16 de abril de 2008

AutoRefresh una pagina web

Para autorefrescar una pagina web tenemos dos maneras

La primera es simple HTML

<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.dotnetspider.com";>

Esto se pone en el head de la pagina y se especifica el tiempo en segundos

La segunda por .NET

Response.AppendHeader("Refresh", "10; URL=http://www.dotnetspider.com")


 

Cheers :D

martes, 18 de marzo de 2008

Cerrar Pagina ASP.NET

Para cerrar una pagina en ASP.NET solo hay que usar el metodo ClientScript que permite usar un script sin tener que ponerlo en el diseño, primero se pone Page.GetType para que agarre el tipo de la pagina, luego el evento y por ultimo el script que se quiere ejecutar.

ClientScript.RegisterStartupScript(Page.GetType(), "OnLoad", "<script language=javascript>" + "window.close()" + "</script>");

lunes, 18 de febrero de 2008

Error en reporte al poner campos con los mismos nombres pero de tablas diferentes

"the value expression for the textbox uses an aggregate expression without a scope. a scope is required for all aggregates used outside of a data region unless the report contains exactly one data set"


 

Si se nos presenta este error, es probablemente porque estemos agregando campos de varias tablas con el mismo nombre o que estemos usando diferentes tablas de diferentes datasets en el mismo reporte.

En este caso lo que hay que hacer es poner en el expression del campo que este dando error… al final… (el dataset)(underscore)(la tabla)

Ej: =First(Fields!nombre.Value, "dsPrueba_TablaPersonas")

viernes, 15 de febrero de 2008

Cómo instalo el AjaxControlToolkit?

Para instalar el Ajax Control Toolkit

Lo primero que tienes que hacer es descargarlo de ASP.NET/AJAX

  1. te diriges al ToolBox y le das click derecho + Add Tab
  2. En el tab que creaste, haces clic derecho + Choose Items…
  3. En la ventana que aparece, le das a Browse
  4. Buscas la ruta donde descomprimiste el Ajax Control Toolkit
  5. Abres la carpeta SampleWebSite, luego BIN
  6. Y buscas la dll (AjaxControlToolkit.dll)
  7. Le das a OK.. y ya esta instalado

Ya puedes usar todos los recursos del Ajax Control Toolkit

miércoles, 13 de febrero de 2008

Cambiar Formato de Objetos String

Si queremos cambiar el string que se peresenta en un label o un textbox, solo usamos el metodo string.format

el cual solo afecta la presentacion pero no el valor que tiene.


 

Ej.:


 

Esto nos devuelve 40 en vez de 40.00


 

beca = Convert.ToDecimal(txtBeca.Text)*100;

txtBeca.Text = string.Format(" {0:###} ", beca);

sábado, 8 de diciembre de 2007

Adding Images to a ReportViewer Report

An image is a report item that contains a reference to an image that is stored on the report server, embedded within the report, or stored in a database. An image can be a logo or picture that appears once on the report or it can be a picture that is repeated with rows of data. You can also use an image as a background for certain report items. You can get images from the following sources:

  • Database
  • External file share or Web site
  • Embedded locally within the report

You cannot use image files that have been added to a project.

Data-bound images can be displayed from binary data stored in a database. For example, the pictures that appear alongside product names in a product list are database images.

External images are specified as a URL that points to an image file. External images work well for logos and static pictures that are shared among several reports or Web pages.

Local report images are embedded in the report and then referenced. The image data is stored within the report definition and does not exist as a separate file. Embedded images ensure that the images are always available to the report, but they cannot be shared. Embedding an image increases the size of the report definition file. When you embed an image, Report Designer MIME-encodes the image and then stores it as text in the report definition.

How to add an Embedded Image to a Report

  1. Open the client report definition (.rdlc) file in graphical design mode.
  2. From the Report menu, select Embedded Images and add all of the images that you want to use in the report. If the Report menu is not available, click within the report design area.
  3. Drag the image control from the toolbox to the report layout. You must use the image control that is used for ReportViewer reports.
  4. Select the image and then open the Properties window in Visual Studio.
  5. Set Source to Embedded.
  6. Set Value to an image that is embedded in the report definition. You can choose which image to use from a drop-down list.

Using an External or Database Image to a Report

To use a database image, you can specify the database field that contains the image as long as the MIME type is JPG, PNG, or BMP. If the image is stored as a binary object, you must write an expression that converts the image to a supported type.

Using external images in a ReportViewer report is not enabled by default. To use an external image, you must set the EnableExternalImages property in your code. Depending on your network configuration, you might also need to bypass proxy settings to allow the external image to appear. You can add the following settings to the Web.config file to bypass the local proxy. When modifying your Web.config file, be sure to specify the name of the proxy server that is used in your network:

<system.net>

<defaultProxy>

<proxy usesystemdefault = "false"

bypassonlocal = "true"

proxyaddress = "http://<
proxyservername
>:80/" />

<defaultProxy>

</system.net>

Background Images

You can use an image as a background image in the body of the report or in a rectangle, text box, list, matrix, or table. A background image has the same properties as an image. You can also specify how the image is repeated to fill the background of the item.

Note

If you define a background image for the report body, but not the page header or footer, HTML reports will automatically use the same background image in all three regions of the report. If you do not want to use the background image in the header or footer, you must explicitly define a different image for those regions. If you do not want any image to appear in those regions, you can create and assign a small transparent image to the header or footer to create the effect of having no image at all.

To add a background image, do the following:

  • Open the client report definition (.rdlc) file in graphical design mode.
  • Select the report item to which you want to add a background image.

Note

Background images apply only to rectangle, text box, table, matrix, list, or report body items.

  • In the Properties window, expand BackgroundImage, and then do the following:
    • For Source, select External, Embedded, or Database.

Note

To use an image from the project, select External.

  • For Value, type or select an expression that evaluates to the source of the image.

    If the Source property is set to External, the expression must evaluate to a valid path to an image. This can be a static path to an image hosted on a report server, or it can be a path based on a field. If the image is stored in the project, type the name of the image as it appears in the project.

    If the Source property is set to Embedded, the expression must evaluate to the name of an image that is embedded in the report. If the Source property is set to Database, the expression must evaluate to a field that contains binary image data.

  • For MIMEType, select the appropriate MIME type for the image.

Note

MIMEType applies only if the Source property is set to Database. If the Source property is set to External or Embedded, the value of MIMEType is ignored.

For BackgroundRepeat, select Repeat, NoRepeat, RepeatX, or RepeatY.