datalist1数据源SqlDataSource1,更新事件DataList1_UpdateCommand
Button1:Text="更新" CommandName="update关键代码如下:
<script runat="server">
private void DataList1_UpdateCommand(object source,System.Web.UI.WebControls.DataListCommandEventArgs e)
{
TextBox quantity;
quantity= (TextBox)(e.Item.FindControl("Quantity"));
string newQuantity = quantity.Text;
// Add code here to update the Quantity value of the data source
// using the newQuantity variable. Note taht newQuantity is a
// string and would have to be converted to a number. DataList1.EditItemIndex = -1;
DataList1.DataBind(); }
</script><asp:DataList ID="DataList1" Runat="server"
DataSourceID="SqlDataSource1" OnUpdateCommand="DataList1_UpdateCommand"
DataKeyField="ID" EditItemIndex="0" OnCancelCommand ="DataList1_CancelCommand"><asp:Button ID="Button1" Runat="server" Text="更新" CommandName="update" />
Button1:Text="更新" CommandName="update关键代码如下:
<script runat="server">
private void DataList1_UpdateCommand(object source,System.Web.UI.WebControls.DataListCommandEventArgs e)
{
TextBox quantity;
quantity= (TextBox)(e.Item.FindControl("Quantity"));
string newQuantity = quantity.Text;
// Add code here to update the Quantity value of the data source
// using the newQuantity variable. Note taht newQuantity is a
// string and would have to be converted to a number. DataList1.EditItemIndex = -1;
DataList1.DataBind(); }
</script><asp:DataList ID="DataList1" Runat="server"
DataSourceID="SqlDataSource1" OnUpdateCommand="DataList1_UpdateCommand"
DataKeyField="ID" EditItemIndex="0" OnCancelCommand ="DataList1_CancelCommand"><asp:Button ID="Button1" Runat="server" Text="更新" CommandName="update" />
解决方案 »
- 类中 var func = function(){ //这样如何进行定义
- DATALIST中嵌套Gridview,如何提交表单数据?
- 请问这样如何实现?
- 一个初学者求教测试为什么有错误,是不是我Microsoft.NET Framework没有安装好阿
- .net中怎么连DB2的数据库,在线等。。。(狂送分)
- IIS 发布网站出现The given key was not present in the directionary.
- (急........)菜鸟第一次在CSDN发帖,0分求教各位大侠一.NET问题.
- isapi的用法
- [求助]IIS设置成集成windows验证,asp.net设成模拟身份验证,为何不能正常登录?
- 有关动态生成.NET控件问题。
- 关于弹出窗口的问题!?在线等!!!!!!!!
- 100分求解一windows应用程序的小问题
quantity= (TextBox)(e.Item.FindControl("Quantity"));
string newQuantity = quantity.Text;==============================================================
你现在只是把编辑的值读出来而已,并没有更新的语句呀。