update issue

4 replies. Last post: September 8, 2010 9:08 PM by Frank Bruce
Tags :
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();
        }

Answers

Hello Zhang, 

When you double click a cell and change the value, you would need to have shift+enter, to update the value. Is this what you are looking for?
Please let me know more details such as your runable sample. 

As I said before, you would also need to handle your update process manually. I don't know what query that you should use. But In my attached sample, I can show you how I handle my update process.

Regards,
Handy

All Replies

Hello,

You could not update because you did not handle an update process in your database.
As far I can see, you only bound the data but did not handle the update.
Normally, you will need to handle it at UpdateRow serverside events.
Since you were using BatchUpdateScenario, you will need to handle at BatchUpdate serverside events.
In this event, you need to call your update query or function.
Shouldn't you have a query or function to update your database?

Regards,
Handy

I have update  query~

i want TO update the any cell  that I have select by dbclick cell !

How to do?

could you please show me a demo !thank you !

Hello Zhang, 

When you double click a cell and change the value, you would need to have shift+enter, to update the value. Is this what you are looking for?
Please let me know more details such as your runable sample. 

As I said before, you would also need to handle your update process manually. I don't know what query that you should use. But In my attached sample, I can show you how I handle my update process.

Regards,
Handy

thank you  Handy:

you are so kind to me~

All times are GMT -5. The time now is 3:46 AM.
Previous Next