Please solve this problem i am new to asp.net programming
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class NewUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
}
protected void NewUser_submit_btn_Click(object sender, EventArgs e)
{
//try
//{
SqlConnection con = new SqlConnection("data source=user\\sqlexpress;" +
"Initial Catalog=TestDB;" +
"Integrated Security=SSPI");
string sql = "INSERT INTO employee VALUES(@empid,@name,@desig,@skill,@teamid,@mgrid,'"+TextBox5.Text+"','"+TextBox6.Text+"','" +TextBox7.Text+ "','"+TextBox8.Text+"',"+TextBox9.Text+","+TextBox10.Text+",'"+TextBox11.Text+"','"+TextBox12.Text+"','"+TextBox13.Text+"')";
using (SqlCommand com = new SqlCommand(sql, con))
{
com.Parameters.AddWithValue("@empid", TextBox1.Text);//Employee ID
com.Parameters.AddWithValue("@name", TextBox2.Text);
com.Parameters.AddWithValue("@desig", TextBox3.Text);
com.Parameters.AddWithValue("@skill", TextBox4.Text);
com.Parameters.AddWithValue("@teamid", DropDownList1.SelectedValue);
com.Parameters.AddWithValue("@mgrid", ""); //when I entring values in employee id textbox that value should be added there in dropdownlist2 and it should be displayed at every time
}
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
}
shyleshs
0
Newbie Poster
Recommended Answers
Jump to PostOK, if you want the dropdownlist2 to show the newly entered data and everythign before it then then best thing to do is what I suggested above.
1) insert the employee ID into the database
2) on page_load (or call it directly after the insertion) draw the employee info from …
Jump to Postafter the database insertion has completed the simplest thing you can do is this:
dropdownlist2.Items.Add(TextBox1.Text);
Or, better, code up another function that selects the employee ID out of the database and adds the resulting dataset to dropdownlist2. You need to do this anyway if you intend …
All 8 Replies
hericles
289
Master Poster
Featured Poster
shyleshs
0
Newbie Poster
shyleshs
0
Newbie Poster
hericles
289
Master Poster
Featured Poster
shyleshs
0
Newbie Poster
hericles
289
Master Poster
Featured Poster
shyleshs
0
Newbie Poster
HunainHafeez
9
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.