using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class admin_edit_category : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
TextBox bigname= GridView1.FooterRow.FindControl("addbigname").c as TextBox;
string ts = bigname.Text;
SqlDataSource1.InsertParameters["Bigcute_name"].DefaultValue =bigname.Text;
SqlDataSource1.Insert();
}
}为什么 bigname.text的值为空的。?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="edit_category.aspx.cs" Inherits="admin_edit_category" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:xinProductsConnectionString %>" DeleteCommand="DELETE FROM [Bigcute] WHERE [bigcute_id] = @original_bigcute_id AND [Bigcute_name] = @original_Bigcute_name"
InsertCommand="INSERT INTO [Bigcute] ([Bigcute_name]) VALUES (@Bigcute_name)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT bigcute_id,bigcute_name FROM [Bigcute] ORDER BY [bigcute_id]"
UpdateCommand="UPDATE [Bigcute] SET [Bigcute_name] = @Bigcute_name WHERE [bigcute_id] = @original_bigcute_id AND [Bigcute_name] = @original_Bigcute_name">
<DeleteParameters>
<asp:Parameter Name="original_bigcute_id" Type="Int32" />
<asp:Parameter Name="original_Bigcute_name" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Bigcute_name" Type="String" />
<asp:Parameter Name="original_bigcute_id" Type="Int32" />
<asp:Parameter Name="original_Bigcute_name" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Bigcute_name" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="bigcute_id"
DataSourceID="SqlDataSource1" Width="50%" ShowFooter="True">
<Columns>
<asp:TemplateField HeaderText="bigcute_id" InsertVisible="False" SortExpression="bigcute_id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("bigcute_id") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("bigcute_id") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label3" runat="server" Text="添加新类:"></asp:Label></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bigcute_name" SortExpression="Bigcute_name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Bigcute_name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Bigcute_name") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="addbigname" runat="server"></asp:TextBox></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" Text="增加" OnClick="Button1_Click" /></FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class admin_edit_category : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
TextBox bigname= GridView1.FooterRow.FindControl("addbigname").c as TextBox;
string ts = bigname.Text;
SqlDataSource1.InsertParameters["Bigcute_name"].DefaultValue =bigname.Text;
SqlDataSource1.Insert();
}
}为什么 bigname.text的值为空的。?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="edit_category.aspx.cs" Inherits="admin_edit_category" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:xinProductsConnectionString %>" DeleteCommand="DELETE FROM [Bigcute] WHERE [bigcute_id] = @original_bigcute_id AND [Bigcute_name] = @original_Bigcute_name"
InsertCommand="INSERT INTO [Bigcute] ([Bigcute_name]) VALUES (@Bigcute_name)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT bigcute_id,bigcute_name FROM [Bigcute] ORDER BY [bigcute_id]"
UpdateCommand="UPDATE [Bigcute] SET [Bigcute_name] = @Bigcute_name WHERE [bigcute_id] = @original_bigcute_id AND [Bigcute_name] = @original_Bigcute_name">
<DeleteParameters>
<asp:Parameter Name="original_bigcute_id" Type="Int32" />
<asp:Parameter Name="original_Bigcute_name" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Bigcute_name" Type="String" />
<asp:Parameter Name="original_bigcute_id" Type="Int32" />
<asp:Parameter Name="original_Bigcute_name" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Bigcute_name" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="bigcute_id"
DataSourceID="SqlDataSource1" Width="50%" ShowFooter="True">
<Columns>
<asp:TemplateField HeaderText="bigcute_id" InsertVisible="False" SortExpression="bigcute_id">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("bigcute_id") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("bigcute_id") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label3" runat="server" Text="添加新类:"></asp:Label></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bigcute_name" SortExpression="Bigcute_name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Bigcute_name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Bigcute_name") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="addbigname" runat="server"></asp:TextBox></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" Text="增加" OnClick="Button1_Click" /></FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>
解决方案 »
- 从Webservice获取的数据集DataSet插入到本的Access???
- Cache所在的命名空间是啥?
- 管理软件销售人员的一个特点是善于把软件价值说得很大,ERP一上线,感觉企业管理水平马上要直追世界500强了。殊不知世界500强中还有很多没有上ERP的,上了ERP的500强每年都有倒闭的。
- 母版页中,ContentPlaceHolder怎样才能居中?
- sql子查询问题,大家不要笑我.谢谢
- 大家好,本人求一水晶报表嵌套子报表的实例或代码,多谢!!!
- 那位兄台可以发一分《asp.net数据库入门经典》一门的电子版和源码以及《vb.net技术内幕》,分不够再加!![email protected]邮件联系也
- 谁知道有在asp.net上实现工作流系统的较好的平台?
- 急!! .net post 跨域请求一个页面,获取参数,插入到数据库
- 希望大神们帮我看看这个!感激
- 请教!asp.net开发使用orcale数据库做起来方不方便的?
- 请教一个发送电子邮件的问题
string ts = ((TexBox)GridView1.FindControl("addbigname")).Text
不在columns里的,
而GridView1.EmptyDataTemplate.FindControl找不到这个方法