[Solved] ASP.Net Error: Cannot implicitly convert type System.Web.UI.Control to string

on Oct 20, 2021 02:44 AM

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: CS0029: Cannot implicitly convert type 'System.Web.UI.Control' to 'string' Source Error:

Line 102:            string STATUS_ID = (GridView1.Rows[e.RowIndex].FindControl("DropDownList2") as DropDownList).SelectedItem.Value;
Line 103:            string ATTEND_BY = (GridView1.Rows[e.RowIndex].FindControl("DropDownList1") as DropDownList).SelectedItem.Value;
Line 104:            string REMARKS = (GridView1.Rows[e.RowIndex].FindControl("TextBox1.text") );
Line 105:            string COMP_ID = GridView1.DataKeys[e.RowIndex].Value.ToString();
Line 106:            string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;


Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Oct 20, 2021 05:37 AM
indradeo says:
            string REMARKS = (GridView1.Rows[e.RowIndex].FindControl("TextBox1.text") );

 Replace with below code.

string REMARKS = (GridView1.Rows[e.RowIndex].FindControl("TextBox1") as TextBox).Text;