-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddQuestions.aspx.cs
68 lines (62 loc) · 1.96 KB
/
AddQuestions.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
public partial class AddQuestions : System.Web.UI.Page
{
string subject;
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex.Equals(1))
{
subject = "C";
}
else if (DropDownList1.SelectedIndex.Equals(2))
{
subject = "Cpp";
}
else if (DropDownList1.SelectedIndex.Equals(3))
{
subject = "Java";
}
else if (DropDownList1.SelectedIndex.Equals(4))
{
subject = "JavaScript";
}
else if (DropDownList1.SelectedIndex.Equals(5))
{
subject = "MySql";
}
else if (DropDownList1.SelectedIndex.Equals(6))
{
subject = "C_Sharp";
}
Label1.Visible = true;
Label2.Text = subject;
}
protected void AddQues_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into " + Label2.Text + " values (' " + TextBox1.Text.Trim() + " ' ,' " + TextBox2.Text.Trim() + " ' ,' " + TextBox3.Text.Trim() + " ' ,' " + TextBox4.Text.Trim() + " ' ,' " + TextBox5.Text.Trim() + " ' , ' " + TextBox6.Text.Trim() + " ')", con);
cmd.ExecuteNonQuery();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Admin.aspx");
}
}