aarti yadav

aarti yadav

  • NA
  • 25
  • 4.8k

cant find TetxBox from selectIndexChanged in listview

Oct 21 2014 7:21 AM
i want be able to find a control TextBox from SelectedIndexChanged in listview
 
 
 
TextBox btnModify = (TextBox)item.FindControl("TextBoxL");   // this code is not workign
 
TextBox btnModify = (TextBox)FindControl("TextBoxL");  // i tried this one also but its to not working 
 
protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox btnModify = (TextBox)items.FindControl("TextBoxL");
SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
int myindex = ListView1.SelectedIndex;
string myId = ListView1.DataKeys[myindex][0].ToString();
//testing the value returned correctly
Response.Write(myId);
SqlCommand cmd = new SqlCommand("insert into rply(task_id,comment,rply_name,rpl_date)values('" + myId + "','" + btnModify.Text + "','" + s2 + "','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')", c);
c.Open();
cmd.ExecuteNonQuery();
c.Close();
}
 

Answers (2)