Dear all,
{Kindly don't ignore my question. I will be very thankfull to you if you help me}
Hi friend i am doing project in Asp.net using c# code(front end).My backend( ms sql server). I am helpless kindly help me for my problem.(I am very new to this).
First I created One Student registration form with the fields name,roll number, department,Branch,password.For Branch i kept one dropdownlist box that holds Msc and MCA.
Secondly I created login form with the fields user name and password. Roll number will be their user name for the student. The student use their rollnumber and password to proceed the third form.
I don't know how to write proper and correct codings for my third form So kindly help me.
My third form:
I designed Form with two radio button,two dropdown list box, one text box.
1) Radio button1 is named as Msc and Radio button2 is named as MCA.
2)Dropdown list1 holds sem1,sem2,sem3,sem4 and dropdown list2 holds sem1,sem2,sem3,sem4,sem5,sem6.
3)Dropdown list1 for Msc Radiobutton1 and Dropdown list2 for MCA Radiobutton2.
when a student login using their roll number and password they will get the third form.
Msc roll number starts with 216(but full roll number look like this 216111001...) and MCA roll number starts with 205(but full roll number look like this 205111001...)
1)*So when an Msc student login using their username(i.e., rollnumber) for that student Radio button1 named as Msc and Dropdown list1 holds sem1,sem2,sem3,sem4 must be visible
*Radio button2 named as MCA and Dropdown list2 holds sem1,sem2,sem3,sem4,sem5,sem6 must be invisible
2)*If MCA student login using their username(i.e., rollnumber) for that student Radio button2 named as MCA and Dropdown list2 holds sem1,sem2,sem3,sem4,sem5,sem6 must be visible
*Radio button1 named as Msc and Dropdown list1 holds sem1,sem2,sem3,sem4 must be invisible
This the condition kindly send me codings for my problem i am struggling a lot.
I will be very much thankfull to you...
Loading
Alok UniyalPosted Mar 9, 2013, 4:15 AM
In form3 you have to find roll no of logged student on page load event of form.
{
RadioButton1.Visible=true;
DropDownList1.Visible=true;
RadioButton2.Visible=false;
DropDownList2.Visible=false;
}
else if(startstring=="205")
{
RadioButton2.Visible=true;
DropDownList2.Visible=true;
RadioButton1.Visible=false;
DropDownList1.Visible=false;
}
Satyapriya NayakPosted Mar 9, 2013, 4:09 AM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Sample_pro
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.Text;
com.CommandText = "insert into register values(@name,@rollnumber,@department,@Branch,@password)";
com.Parameters.Clear();
com.Parameters.AddWithValue("@name", TextBox1.Text);
com.Parameters.AddWithValue("@rollnumber", TextBox2.Text);
com.Parameters.AddWithValue("@department", TextBox3.Text);
com.Parameters.AddWithValue("@Branch", DropDownList1.SelectedValue);
com.Parameters.AddWithValue("@password", TextBox4.Text);
if (con.State == ConnectionState.Closed)
con.Open();
com.ExecuteNonQuery();
con.Close();
lblmsg.Text = "Data entered successfully!!!";
clear();
}
private void clear()
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
DropDownList1.ClearSelection();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("Select");
DropDownList1.Items.Add("msc");
DropDownList1.Items.Add("mca");
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Sample_pro.login" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Sample_pro
{
public partial class login : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str, rollnumber, password;
SqlCommand com;
SqlDataAdapter sqlda;
DataTable dt;
int RowCount;
protected void btn_login_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "Select * from register";
com = new SqlCommand(str);
sqlda = new SqlDataAdapter(com.CommandText, con);
dt = new DataTable();
sqlda.Fill(dt);
RowCount = dt.Rows.Count;
for (int i = 0; i < RowCount; i++)
{
rollnumber = dt.Rows[i]["rollnumber"].ToString();
password = dt.Rows[i]["password"].ToString();
if (rollnumber == TextBox_user_name.Text && password == TextBox_password.Text)
{
Session["rollnumber"] = rollnumber;
if (dt.Rows[i]["Branch"].ToString() == "msc")
Response.Redirect("~/msc/msc.aspx");
else if (dt.Rows[i]["Branch"].ToString() == "mca")
Response.Redirect("~/mca/mca.aspx");
}
else
{
lb1.Text = "Invalid User Name or Password! Please try again!";
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="msc.aspx.cs" Inherits="Sample_pro.msc" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Sample_pro
{
public partial class msc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items.Add("Select");
DropDownList1.Items.Add("sem1");
DropDownList1.Items.Add("sem2");
DropDownList1.Items.Add("sem3");
DropDownList1.Items.Add("sem4");
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mca.aspx.cs" Inherits="Sample_pro.mca" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Sample_pro
{
public partial class mca : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items.Add("Select");
DropDownList1.Items.Add("sem1");
DropDownList1.Items.Add("sem2");
DropDownList1.Items.Add("sem3");
DropDownList1.Items.Add("sem4");
DropDownList1.Items.Add("sem5");
DropDownList1.Items.Add("sem6");
}
}
}