hi here is windows form code i want this code for my website project.can any one help me ??how can i give code for my aspx page.i wanna display same output in my aspx page as displayed in winform
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Clear();
dataGridView1.ColumnCount = 10;
dataGridView1.RowCount = 10;
dataGridView1.Columns[0].Width = 100;
dataGridView1.Columns[1].Width = 100;
dataGridView1.Columns[2].Width = 20;
dataGridView1.Columns[3].Width = 100;
dataGridView1.Columns[4].Width = 100;
dataGridView1.Columns[5].Width = 20;
dataGridView1.Columns[6].Width = 100;
dataGridView1.Columns[7].Width = 100;
dataGridView1.Columns[0].HeaderText = "I Row";
dataGridView1.Columns[1].HeaderText = "II Row";
dataGridView1.Columns[2].HeaderText = "";
dataGridView1.Columns[3].HeaderText = "III Row";
dataGridView1.Columns[4].HeaderText = "IV Row";
dataGridView1.Columns[5].HeaderText = "";
dataGridView1.Columns[6].HeaderText = "V Row";
dataGridView1.Columns[7].HeaderText = "VI Row";
int a = 1, b = 0,c=0;
DateTime d1 = DateTime.Today.Date;
string str1="";
str1 = comboBox1.Text;
d1 = new DateTime(int.Parse(str1.Substring(6, 4)), int.Parse(str1.Substring(3, 2)), int.Parse(str1.Substring(0, 2)));
if (conn.State == ConnectionState.Open) { conn.Close(); }
conn.Open();
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
cmd.Connection = conn;
cmd.CommandText = "select Regno,deskno,deskside,semister from AllotmentTab where RoomNo='" + comboBox3.Text + "' and examdate='" + d1 + "' and esession='" + comboBox2.Text + "' order by Deskno,deskside";
dr = cmd.ExecuteReader();
while (dr.Read())
{
b = int.Parse(dr.GetValue(1).ToString());
if (b > 14)
{ b = b - 14;
c = 6;
}
else if (b > 7)
{ b = b - 7;
c = 3;
}
else
{
c = 0;
}
if (dr.GetValue(2).ToString() == "L")
{
dataGridView1.Rows[b].Cells[c].Value = dr.GetValue(0).ToString() + " (" + dr.GetValue(3).ToString() + ")";
}
else
{
dataGridView1.Rows[b].Cells[c + 1].Value = dr.GetValue(0).ToString() + " (" + dr.GetValue(3).ToString() + ")";
}
a++;
if ((a % 7) == 0)
{
}
}
if (conn.State == ConnectionState.Open) { conn.Close(); }
conn.Open();
SqlCommand cmd5 = new SqlCommand();
SqlDataReader dr5;
cmd5.Connection = conn;
cmd5.CommandText = "select facultycode from fAllotmentTab where RoomNo='" + comboBox3.Text + "' and examdate='" + d1 + "' and esession='" + comboBox2.Text + "'";
dr5 = cmd5.ExecuteReader();
if (dr5.Read())
{
labelmsg.Text = "Alloted Faculty : " + dr5.GetValue(0).ToString();
}
else { labelmsg.Text = "Alloted Faculty : "; }
}
private void RoomwiseDisForm_Load(object sender, EventArgs e)
{
for (int i = 101; i < 111; i++)
{
comboBox3.Items.Add(i.ToString());
}
if (conn.State == ConnectionState.Open) { conn.Close(); }
conn.Open();
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
cmd.Connection = conn;
cmd.CommandText = "select ExamDate from AllotmentTab group by ExamDate order by ExamDate";
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(string.Format("{0:dd-MM-yyyy}",dr.GetValue(0)));
}
}
and this is design code..
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.labelmsg = new System.Windows.Forms.Label();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(475, 28);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(133, 31);
this.button1.TabIndex = 22;
this.button1.Text = "Display";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.labelmsg.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.labelmsg.Location = new System.Drawing.Point(24, 89);
this.labelmsg.Name = "labelmsg";
this.labelmsg.Size = new System.Drawing.Size(431, 16);
this.labelmsg.TabIndex = 21;
this.labelmsg.Text = "Alloted Faculty :";
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(27, 35);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(93, 24);
this.comboBox3.TabIndex = 20;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 16);
this.label1.TabIndex = 19;
this.label1.Text = "Semister";
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(27, 109);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(4);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(971, 485);
this.dataGridView1.TabIndex = 18;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(172, 35);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(165, 24);
this.comboBox1.TabIndex = 24;
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(169, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 16);
this.label2.TabIndex = 23;
this.label2.Text = "Date";
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[] {
"M",
"A"});
this.comboBox2.Location = new System.Drawing.Point(362, 35);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(93, 24);
this.comboBox2.TabIndex = 26;
this.comboBox2.Text = "M";
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(359, 16);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(58, 16);
this.label3.TabIndex = 25;
this.label3.Text = "Session";
this.button2.Location = new System.Drawing.Point(865, 35);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(133, 31);
this.button2.TabIndex = 27;
this.button2.Text = "Close";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1028, 607);
this.Controls.Add(this.button2);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.labelmsg);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGridView1);
this.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "RoomwiseDisForm";
this.Text = "RoomwiseDisForm";
this.Load += new System.EventHandler(this.RoomwiseDisForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
can any one help me..