当我尝试阅读时,GridView错误,从SQL Server显示项目信息
我得到这个错误:
汇编错误
描述:在为此请求的资源的汇编过程中,发生了错误。请查看以下特定错误详细信息并适当修改您的源代码。
编译器错误消息:CS1061:'updateForm_aspx'不包含'gridview1_selectedIndexchanged'的定义,而没有扩展方法” gridview1_selectedIndexchanged'接受类型'UpdateForm_aspx'的第一个参数(您是否丢失了使用Directive或使用Directive a Directive或a -nifferage obsessbly或一个组件参考?)
源错误:
Line 49: </div>
Line 50: </div>
Line 51: <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
Line 52: </asp:GridView>
Line 53: </form>
这是我尝试在GridView上显示信息的地方:
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-62V61RT\SQLEXPRESS; Initial Catalog =ShopOnlineDB; Integrated Security=True;");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Master.Items", con);
SqlDataAdapter dat = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
dat.Fill(dt);
GridView1.DataSource = dt;
I get this error:
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: 'updateform_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'updateform_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 49: </div>
Line 50: </div>
Line 51: <asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
Line 52: </asp:GridView>
Line 53: </form>
This is where I try to show information on GridView:
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-62V61RT\SQLEXPRESS; Initial Catalog =ShopOnlineDB; Integrated Security=True;");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Master.Items", con);
SqlDataAdapter dat = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
dat.Fill(dt);
GridView1.DataSource = dt;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在CS文件中的代码中添加它
Just add this in the code in cs file