
15/05/2006, 10:42
|
| | Fecha de Ingreso: mayo-2006
Mensajes: 243
Antigüedad: 18 años, 10 meses Puntos: 0 | |
Problemas al usar command Hola!
Tengo 6 botones.
3 de ellos me traen una serie de 10, 15 y 20 número impares respectivamente y los otros 3 me traen una serie de 10, 15 y 20 números impares respectivamente.
Seleccioné todos los botones en el Design y en la propiedad Command puse: EvenOdd_Command, dentro de mi .cs agregué el siguiente código:
private void EvenOdd_Command(object sender,
System.Web.UI.WebControls.CommandEventArgs e)
{
//Get the command specified for the Button
string strEvenOdd =e.CommandName;
//Get the command argument for the Button
int intTimes =Convert.ToInt32(e.CommandArgument);
StringBuilder sbResults =new StringBuilder();
for (int i =0;i<intTimes;i++)
{
//Generate a Odd/Even number
sbResults.Append(
String.Format("{0}number {1} is: {2}<br>",
strEvenOdd, i+1,
(strEvenOdd =="Odd" ? i*2+1 : i*2)));
}
//Store the final results in a label control
lblResults.Text =sbResults.ToString();
}
y al principio de mi clase puse: using System.Text;
Los botones que muestran los impares (Odd) tienen la propiedad CommandName = Odd
Los botones que muestran los pares tienen la propiedad CommandName = Even
El Command Argument es de 10, 15 y 20 segun la cantidad de numeros a mostrar por cada botón
Al darle Debug no me marca errores, pero al momento de dar click en un botón no me muestra nada de resultados
Saludos |