Code behind is not seeing textbox inside datalist
see error
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'txtComments' does not exist in the current context
Source Error:
Line 339: {
Line 340:
Line 341: string tendString = txtComments.Text.Trim();
Line 342:
Line 343:
code
string str = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string getADPOST = "Insert INTO USERPost (UserName,FriendUserName,SharedUserName,MessageStatus,Symbol,ContentPost,ImageName1) values (@UserName,NULL,NULL,NULL,NULL,@ContentPost,@ImageName1)";
// string getADPOST = "Insert INTO CommunityFollow (MyUserName,FriendUserName,CommunityStatus) values (@MyUserName,@FriendUserName,1)";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
// Get Filename from fileupload control
// string filename = Path.GetFileName(FileUploadImage.PostedFile.FileName);
// Save images into Images folder
// Server.MapPath("~/UserImage/" + FileUploadImage.FileName);
// cmd.Parameters.AddWithValue("@ImageName1", filename);
// cmd.Parameters.AddWithValue("@ImageName1", "~/UserImage/" + filename);
cmd.Parameters.AddWithValue("@ContentPost", txtComments.Text.Trim());
cmd.Parameters.AddWithValue("@UserName", username);
cmd.Parameters.AddWithValue("@FriendUserName", username);
cmd.Parameters.AddWithValue("@Id", username);
// cmd.Parameters.AddWithValue("@ImageName1", strname);
// con.Open();
// SqlCommand cmd = new SqlCommand("insert into yourTable (FilePath) values('" + strname + "')", con);
// cmd.ExecuteNonQuery();
// cmd.Parameters.AddWithValue("@FriendUserName", Request.QueryString["Id"].ToString());
//cmd.Parameters.AddWithValue("@Id", Session["Id"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
}
}