How to call the xyz_InsertObject(object sender,EventArgs e) event from the button click event

How to call the xyz_InsertObject(object sender,EventArgs e) event from the button click event

Old forum URL: forums.lhotka.net/forums/t/9324.aspx


sirak posted on Thursday, August 05, 2010

Hi guys

i have a gridview control whis is bind to the itemDatasourceCsla datasource ....and i want to add a new row to the gridview control ....and configure the footer to accept new row and also add an insert link button....here the question is i want to call the itemdatasourceCsla datasource insertObject() event from this insert button ....pls help.....look like this(it is webbased)

 

 

 

protected void ItemCslaDataSource_InsertObject(object sender, Csla.Web.InsertObjectArgs e)

 

 

{

code to insert item ....look the question from lnkInset_Click event...

{

protected void lnkInsert_Click(object sender, EventArgs e)

{

//i want to call the obove event from here....help pls

}

 

 

 

 

 

 

RockfordLhotka replied on Thursday, August 05, 2010

That is not the way Web Forms data binding works.

In Web Forms, you tell the UI control (datagridview, detailsview, etc) that you want to insert an item, and the UI control tells data binding it wants a new item, and data binding tells the datasource control it wants a new item. That's when the CslaDataSource control raises the event to get a new item.

This isn't a CSLA thing - this is the way Web Forms is designed to work. So you can find examples and information on inserting items from pretty much any decent Web Forms book.

sirak replied on Friday, August 06, 2010

Thanks Rocky for your replay ....the problem i encounter is that by default Gridview control doesn't have option to insert new row....so i have to manually create an insert button in the footer template with the associated textbox control to insert data,and give my insert link button command name Insert ,then from this click event of the link button i want to execute the InsertObject of csla ...b/c it is here that i write code to insert my data....

 

 

RockfordLhotka replied on Friday, August 06, 2010

It has been a few years since I did web forms work, so I don't remember the specifics - but I do know there's a way to have the datagridview do an insert operation. As I remember it, the process is somewhat awkward - but it does work more or less as I described in my previous post.

Copyright (c) Marimer LLC