Code:
using SchoolManagementSystem.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using static SchoolManagementSystem.Models.CommonFn;
namespace SchoolManagementSystem.Admin
{
public partial class AddClass : System.Web.UI.Page
{
commonfnx fn = new commonfnx();
private object txtClass;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
GetClass();
}
}
private void GetClass()
{
DataTable dt = fn.Fetch("select.Row_NUMBER() over (order by (select 1) as [sr.No],ClassId,ClassName from class");
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void btnadd_Click(object sender, EventArgs e)
{
try
{
DataTable dt = fn.Fetch("select * from Class where ClassName = '"+txtClass.text.Trim()+"'");
{
if (dt.Rows.Count==0)
{
string query = "Insert into Class values('" + txtClass.Text.Trim() + "')";
fn.Query(query);
lblMsg.Text = "inserted Successful";
lblMsg.CssClass = "alert alert-success";
txtClass.Text = string.Empty;
GetClass();
}
else
{
}
}
}
catch(Exception ex)
{
}
}
}
}
I want to solve the CS1061 error.
When I add .text I get this error
'Object' does not contains a defintion for 'Text' and no accessible extension method text accepting a first argument of type 'object' could be found
How to insert the data into the SQL Server database? Please help me out.