ASP.NET 编译器错误消息: CS1061:
“string”不包含“Value”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“Value”(是否缺少using指令或程序集引用?)<asp:G...
“string”不包含“Value”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“Value”(是否缺少 using 指令或程序集引用?)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" onrowdeleting="Gridview1_RowDeleting">
<Columns>
<asp:BoundField HeaderText="编号" />
<asp:BoundField DataField="title" HeaderText="标题" />
<asp:BoundField DataField="pubtime" DataFormatString="{0:d}"
HeaderText="发布时间" />
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="删除" CommandName = "delete" OnClientClick ='return confirm ("您确定要删除吗?")' />
<asp:HyperLink ID="HyperLink1" runat="server">修改</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
cs代码:
行 38: protected void Gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e)
行 39: {
行 40: string sql = "delete from article where id = " + this.GridView1.DataKeyNames[e.RowIndex].Value;
行 41: DB1.Sql.ExecuteNonQuery(CommandType.Text, sql);
行 42: this.db(1);
} 展开
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" onrowdeleting="Gridview1_RowDeleting">
<Columns>
<asp:BoundField HeaderText="编号" />
<asp:BoundField DataField="title" HeaderText="标题" />
<asp:BoundField DataField="pubtime" DataFormatString="{0:d}"
HeaderText="发布时间" />
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="删除" CommandName = "delete" OnClientClick ='return confirm ("您确定要删除吗?")' />
<asp:HyperLink ID="HyperLink1" runat="server">修改</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
cs代码:
行 38: protected void Gridview1_RowDeleting(object sender, GridViewDeleteEventArgs e)
行 39: {
行 40: string sql = "delete from article where id = " + this.GridView1.DataKeyNames[e.RowIndex].Value;
行 41: DB1.Sql.ExecuteNonQuery(CommandType.Text, sql);
行 42: this.db(1);
} 展开
2个回答
展开全部
是不是缺少using 指令using System.Data.SqlClient;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询