本文介绍了在运行时显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显示错误
showing 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: CS1061: 'ASP.webform1_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.webform1_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 11: <div>
Line 12:
Line 13: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Line 14: BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
Line 15: CellPadding="3" onselectedindexchanged="GridView1_SelectedIndexChanged"
Source File: c:\Users\manish\Desktop\my vb program\WebApplication7\WebApplication7\WebForm1.aspx Line: 13
我尝试过:
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
namespace WebApplication7
{
public partial class WebForm1 : System.Web.UI.Page
{
public OleDbConnection con;
public OleDbCommand cmd;
public OleDbDataAdapter adt;
public DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
fillGridData();
}
}
private void fillGridData()
{
con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\manish\Desktop\my vb program\test.accdb");
con.Open();
adt = new OleDbDataAdapter("select * from demo",con);
ds=new DataSet();
adt.Fill(ds);
GridView1.DataSource=ds;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\manish\Desktop\my vb program\test.accdb");
con.Open();
string data1;
string cname;
string cmobile;
string caddress;
cname=(GridView1.FooterRow.FindControl("TextBox1") as TextBox).Text;
cmobile=(GridView1.FooterRow.FindControl("TextBox2") as TextBox).Text;
caddress=(GridView1.FooterRow.FindControl("TextBox3") as TextBox).Text;
data1="insert into demo values("+ cname+",'"+ cmobile +"','"+ caddress +"')";
cmd = new OleDbCommand(data1,con);
cmd.ExecuteNonQuery();
con.Close();
fillGridData();
Label4.Text ="data saved successfully";
}
}
}
推荐答案
'ASP.webform1_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged'
什么是寻找名为GridView1_SelectedIndexChanged的方法?看看你的gridview定义
What is is looking for a method called GridView1_SelectedIndexChanged? Look at your gridview definition
onselectedindexchanged="GridView1_SelectedIndexChanged"
好的,现在看看你的代码隐藏了,你有一个名为GridView1_SelectedIndexChanged的方法吗?不,所以当选择的索引更改事件被触发时它不知道该怎么办。
如果你对这个事件感兴趣,你需要添加这个事件 - 代码隐藏的处理程序,如果您对该事件不感兴趣,请从gridview定义中删除相关属性。
]
这篇关于在运行时显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!