update issue

4 replies. Last post: September 8, 2010 9:08 PM by Frank Bruce
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Frank BruceMember

when I  use under way to bind webgrid,I can not update Row(0)("name")="zxy" by "btnclick()" !

I think the reason is:webgrid does not have "UpdateCommand",but I do not know that How to write "UpdateCommand"( I do not want to use SqlDataSource)

Please help me how to write "UpdateCommand" by the bind way!!

c# code

 

 <ISWebGrid:WebGrid runat="server" ID="webgrid2"     
         UseDefaultStyle="True" DefaultStyleMode="Win7" 
            oninitializedatasource="webgrid2_InitializeDataSource"
       >
<LayoutSettings    AllowAddNew="Yes" allowDelete="Yes"  AllowEdit="Yes">                   <ClientSideEvents OnAfterExitEditMode="OnExitEdit"/>        
</LayoutSettings>
     <RootTable DataKeyField="序列号">
        <Columns>
         <ISWebGrid:WebGridColumn Name="序列号" IsRowChecker="true" Caption="序列号">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="商品编号"  Caption="商品编号" DataMember="商品编号">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="name"  Caption="name" DataMember="name">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="商品规格"  Caption="商品规格" DataMember="商品规格">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="商品单位"  Caption="商品单位" DataMember="商品单位">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="数量"  Caption="数量" DataMember="数量">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="无税单价" Caption="无税单价" DataMember="无税单价">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="含税单价"  Caption="含税单价" DataMember="含税单价">
                </ISWebGrid:WebGridColumn>
                 <ISWebGrid:WebGridColumn Name="备注" Caption="备注" DataMember="备注">
                </ISWebGrid:WebGridColumn>
        </Columns>
        </RootTable>
            </ISWebGrid:WebGrid> 
protected void webgrid2_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e){                                          e.DataSource =da.QuerySql(); //a dataset of sql query in sql database  } 

JS code: 

 function btnclick()
        {
var grid= ISGetObject("webgrid2");
grid.RootTable.GetRow(0).GetCells().GetNamedItem("name").SetText('zxy', true); grid.RootTable.GetRow(0).Update(); grid.RootTable.GetRow(0).AcceptChanges();
        }
All times are GMT -5. The time now is 8:50 PM.
Previous Next