Asyraf MN

Asyraf MN

  • NA
  • 28
  • 7.8k

How to display output one by one in label

Mar 29 2018 7:55 PM
Currently i'm working on lucky draw system. I've already can call out the result when clicking button draw. But i want it to show one by one or with some animated function on output. Can anyone share some ideas/ solution. Thanks.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Configuration;  
  4. using System.Data;  
  5. using System.Data.SqlClient;  
  6. using System.IO;  
  7. using System.Linq;  
  8. using System.Web;  
  9. using System.Web.UI;  
  10. using System.Web.UI.WebControls;
  11. public partial class _Default : System.Web.UI.Page     
  12. {  
  13.     string constr = ConfigurationManager.ConnectionStrings["lucky"].ConnectionString;  
  14.     protected void Page_Load(object sender, EventArgs e)  
  15.     {
  16.     }
  17.     protected void Button1_Click(object sender, EventArgs e)  
  18.     {  
  19.         string query = "SELECT TOP 1[EMP_ID]FROM EMPLOYEES WHERE[Attendance] = 'Present'ORDER BY NEWID()";  
  20.   
  21.         using (SqlConnection con = new SqlConnection(constr))  
  22.         {  
  23.             using (SqlCommand cmd = new SqlCommand(query))  
  24.             {  
  25.                 using (SqlDataAdapter sda = new SqlDataAdapter())  
  26.                 {  
  27.                     cmd.Connection = con;  
  28.                     sda.SelectCommand = cmd;  
  29.                     using (DataTable dt = new DataTable())  
  30.                     {  
  31.                         sda.Fill(dt);  
  32.                         if (dt.Rows.Count > 0)  
  33.                         {  
  34.                             Label1.Text = dt.Rows[0]["EMP_ID"].ToString();
  35.                         }  
  36.                         else  
  37.                         {  
  38.                             Label1.Text += "Cannot draw! ";  
  39.                         }  
  40.                     }  
  41.                 }  
  42.             }  
  43.         }  
  44.     }  
  45. }

Answers (2)