代码:
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT [departmentid], [departmentname], [departmentcount], [updatetime] FROM [department_tbl]" UpdateCommand="update [department_tbl] set [departmentname] = @departmentname,[departmentcount] = @departmentcount where [departmentid] = @old_departmentid " OldValuesParameterFormatString="old_{0}">
</asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2"
Width="100%" AllowPaging="True" PageSize="20" DataKeyNames="departmentid">
<Columns>
<asp:BoundField DataField="departmentid" HeaderText="单位id" InsertVisible="False"
ReadOnly="True" >
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="departmentname" HeaderText="单位名" >
<ItemStyle HorizontalAlign="Center" Width="25%" />
</asp:BoundField>
<asp:BoundField DataField="departmentcount" HeaderText="单位说明" >
<ItemStyle HorizontalAlign="Center" Width="35%" />
</asp:BoundField>
<asp:BoundField DataField="updatetime" HeaderText="填加时间" SortExpression="updatetime" InsertVisible="false">
<ItemStyle HorizontalAlign="Center" Width="15%" />
</asp:BoundField>
<asp:CommandField HeaderText="管理" ShowDeleteButton="True" ShowEditButton="True">
<ItemStyle HorizontalAlign="Center" Width="15%" />
</asp:CommandField>
</Columns>
</asp:GridView>
错误提示:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------必须声明变量 '@departmentname'。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 必须声明变量 '@departmentname'。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪:
[OleDbException (0x80040e14): 必须声明变量 '@departmentname'。]
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +764
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +401
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +721
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +858
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.210
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT [departmentid], [departmentname], [departmentcount], [updatetime] FROM [department_tbl]" UpdateCommand="update [department_tbl] set [departmentname] = @departmentname,[departmentcount] = @departmentcount where [departmentid] = @old_departmentid " OldValuesParameterFormatString="old_{0}">
</asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2"
Width="100%" AllowPaging="True" PageSize="20" DataKeyNames="departmentid">
<Columns>
<asp:BoundField DataField="departmentid" HeaderText="单位id" InsertVisible="False"
ReadOnly="True" >
<ItemStyle HorizontalAlign="Center" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="departmentname" HeaderText="单位名" >
<ItemStyle HorizontalAlign="Center" Width="25%" />
</asp:BoundField>
<asp:BoundField DataField="departmentcount" HeaderText="单位说明" >
<ItemStyle HorizontalAlign="Center" Width="35%" />
</asp:BoundField>
<asp:BoundField DataField="updatetime" HeaderText="填加时间" SortExpression="updatetime" InsertVisible="false">
<ItemStyle HorizontalAlign="Center" Width="15%" />
</asp:BoundField>
<asp:CommandField HeaderText="管理" ShowDeleteButton="True" ShowEditButton="True">
<ItemStyle HorizontalAlign="Center" Width="15%" />
</asp:CommandField>
</Columns>
</asp:GridView>
错误提示:
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------必须声明变量 '@departmentname'。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 必须声明变量 '@departmentname'。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪:
[OleDbException (0x80040e14): 必须声明变量 '@departmentname'。]
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +764
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +401
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +721
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +858
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.210
解决方案 »
- marquee属性是使字幕滚动的,有什么办法能让需要滚动的字幕首尾相连着滚动呢,意思就是不要等一条信息的内容滚动完,后面出现好大空白
- 研究过JavaScript和flash交互的朋友进来看看.
- 各位高手拜托帮帮我的忙啊啊啊啊啊~~~
- 如何制作POPUP广告页?
- asp.net视频
- 在TreeView中使用了checkbox,如何将checkbox变成不可选的状态?即变成灰色
- 分页的dataset存在session是否合理,以及多少数据量时开始考虑自定义分页?
- 高难问题,只求散分!!!!!!!!--如何对已编译的Server Control进行动态调试?????
- 请问一个超简单问题,看看下面的代码有什么错误?
- 采用form验证并且设置不允许匿名访问后,访问web service代理类出错
- .net 2.0 怎么支持cook不是太好!!---请教
- 今年最后一个小问题:正则提取的问题
你的gridview的邦定中应该有一个输入输出的departmentname才行
<updateParameters>
//这写出departmentname的调用
</updateParameters>
//这写出departmentname的调用
</updateParameters>
这个我也加了,但是好像也不行
<UpdateParameters>
<asp:Parameter Name="departmentname" Type="string"/>
</UpdateParameters>
还提示这个错误
SQLDataSource的select,update,delete都有相应的语句(这个你自己有了)也就是GridView显示通过你select方法返回的记录集,显示的时候有个DataField邦定,其中有departmentname字段,你用Bind,也就是双向,不要用Eval(单向)这样说不知明白否?