Click here to Skip to main content
15,914,016 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: URL Rewriting Pin
Manas Bhardwaj28-May-09 3:42
professionalManas Bhardwaj28-May-09 3:42 
GeneralRe: URL Rewriting Pin
Matt Cavanagh28-May-09 20:28
Matt Cavanagh28-May-09 20:28 
Question[Message Deleted] Pin
llibin27-May-09 20:14
llibin27-May-09 20:14 
AnswerRe: Give me urgent solution Pin
Vimalsoft(Pty) Ltd27-May-09 20:41
professionalVimalsoft(Pty) Ltd27-May-09 20:41 
AnswerRe: [Message Deleted] Pin
Baran M27-May-09 21:12
Baran M27-May-09 21:12 
Questionhow to use Query string in asp.net Pin
kumar Rajiv27-May-09 19:55
kumar Rajiv27-May-09 19:55 
AnswerRe: how to use Query string in asp.net Pin
Baran M27-May-09 20:10
Baran M27-May-09 20:10 
AnswerRe: how to use Query string in asp.net Pin
padmanabhan N27-May-09 20:15
padmanabhan N27-May-09 20:15 
//insert to database
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();

string empcode = txtempcode.Text;
string empname = txtEmpname.Text;

SqlCommand com = new SqlCommand();
com.Connection = con;

com.CommandText = "insert into ankemp values(@empcode,@empname)";
com.Parameters.Add("@empcode", empcode);
com.Parameters.Add("@empname", empname);
com.ExecuteNonQuery();
bindgrid();

//datasource to grid
void bindgrid()
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();

string query = "select * from ankemp";
SqlDataAdapter da = new SqlDataAdapter(query.ToString(), con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}

//while clicking the fetch button in grid (in aspx page <commandname="fetch" commandargument="<%# Bind("empcode") >">
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "fetch")
{
int empcode = int.Parse(e.CommandArgument.ToString());
fetch(empcode);
}
}
//fetch method
public void fetch(int empcode)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
txtempcode.Text = empcode.ToString();

StringBuilder sb = new StringBuilder();
sb.Append(" select empname, ");
sb.Append(" from ankemp where empcode="+empcode);
SqlCommand com = new SqlCommand(sb.ToString(), con);
SqlDataReader dr = com.ExecuteReader();

if (dr.Read())
{
txtEmpname.Text = dr["empname"].ToString();
}
//update
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
string empcode = txtempcode.Text;
string empname = txtEmpname.Text;

string update = "update ankemp set empname='" + empname + "'where empcode='" + empcode + "'";
SqlCommand cmd = new SqlCommand(update, con);
cmd.ExecuteNonQuery();
bindgrid();
con.Close();

//deleteing (in aspx page <commandname="delete">
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
int i = e.RowIndex;

string empcode = GridView1.Rows[i].Cells[0].Text;
string del = "delete from ankemp where empcode='" + empcode + "'";
SqlCommand com = new SqlCommand(del, con);
com.ExecuteNonQuery();
bindgrid();
}

Padmanabhan

Questionhelp meeee Pin
llibin27-May-09 19:48
llibin27-May-09 19:48 
AnswerRe: help meeee Pin
saanj28-May-09 2:43
saanj28-May-09 2:43 
QuestionExecute external page Pin
Yosh_27-May-09 18:48
professionalYosh_27-May-09 18:48 
AnswerRe: Execute external page Pin
Baran M27-May-09 19:24
Baran M27-May-09 19:24 
GeneralRe: Execute external page Pin
Yosh_28-May-09 0:47
professionalYosh_28-May-09 0:47 
AnswerRe: Execute external page Pin
Vimalsoft(Pty) Ltd27-May-09 21:03
professionalVimalsoft(Pty) Ltd27-May-09 21:03 
GeneralRe: Execute external page Pin
Baran M27-May-09 23:01
Baran M27-May-09 23:01 
GeneralRe: Execute external page Pin
Vimalsoft(Pty) Ltd28-May-09 0:28
professionalVimalsoft(Pty) Ltd28-May-09 0:28 
Questionplugins for asp.net Pin
antew27-May-09 11:52
antew27-May-09 11:52 
AnswerRe: plugins for asp.net Pin
Yusuf27-May-09 12:42
Yusuf27-May-09 12:42 
QuestionLogin Contorls Pin
hahii27-May-09 11:30
hahii27-May-09 11:30 
AnswerRe: Login Contorls Pin
Ramesh Swaminathan27-May-09 18:45
Ramesh Swaminathan27-May-09 18:45 
QuestionTextBox in Gridview retaining old value Pin
dreamaway82027-May-09 11:11
dreamaway82027-May-09 11:11 
AnswerRe: TextBox in Gridview retaining old value Pin
padmanabhan N27-May-09 15:51
padmanabhan N27-May-09 15:51 
GeneralRe: TextBox in Gridview retaining old value Pin
dreamaway82028-May-09 3:19
dreamaway82028-May-09 3:19 
GeneralRe: TextBox in Gridview retaining old value Pin
Herman<T>.Instance28-May-09 5:05
Herman<T>.Instance28-May-09 5:05 
GeneralRe: TextBox in Gridview retaining old value Pin
dreamaway82028-May-09 5:25
dreamaway82028-May-09 5:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.