【发布时间】:2017-02-12 19:06:49
【问题描述】:
我正在使用链接按钮通过文本框在 asp.net 网格视图中插入数据。但尽管代码正确,但我的按钮没有执行操作。 这是我的 ASPX 代码
<FooterTemplate>
<asp:LinkButton ID="Insertkey" OnClick="Insertkey_Click" runat="server">INSERT</asp:LinkButton>
</FooterTemplate>
这是我的 C# 代码
protected void Insertkey_Click(object sender, EventArgs e)
{
SqlDataSource1.InsertParameters["Title"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("Tbox")).Text;
SqlDataSource1.InsertParameters["Pic"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("Pbox")).Text;
SqlDataSource1.InsertParameters["Content"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("Cbox")).Text;
}
请帮我解决我的问题。
【问题讨论】:
-
如果您在 Insertkey_Click 中设置断点,是否会触发该代码?突出的一件事是代码“GridView1.FooterRow.FindControl("Pbox")).Text”正在从页脚中查找控件。您的页脚模板代码中不存在此控件
标签: c# asp.net sql-server gridview