Hello
I need to generate a postback when exit of a cell in RowAdding. I achieved something like this, with event RowUpdating. I did, in page aspx:
<asp:UpdatePanel runat="server" ID="SampleUpdatePanel"><ContentTemplate>
<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyFields="OrderID" OnRowUpdating="WebDataGrid1_RowUpdating">
.
<Behaviors> <ig:Activation> </ig:Activation> <ig:EditingCore AutoCRUD="False"> <Behaviors> <ig:CellEditing> <CellEditingClientEvents ExitedEditMode="WebDataGrid1_CellEditing_ExitedEditMode" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> <ig:Selection CellClickAction="Row" RowSelectType="Single"> </ig:Selection> <ig:RowSelectors> </ig:RowSelectors></Behaviors>
</ig:WebDataGrid>
</ContentTemplate></asp:UpdatePanel>
<script type="text/javascript">function WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs) {
__doPostBack('<%= SampleUpdatePanel.ClientID %>', '');}
</script>
Therefore, with this, it generates a postback every time it exits to edit a cell (any cell, not necessarily the whole row) and enters in the following event:
protected void WebDataGrid1_RowUpdating(object sender, RowUpdatingEventArgs e){
//My code
}
This is okay, because it's just what I need.
Now, I need to make the same, but in this case, in a RowAdding event. I did something like this, in page aspx:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyFields="OrderID" OnRowUpdating="WebDataGrid1_RowUpdating" OnRowAdding="WebDataGrid1_RowAdding">
<Behaviors>
<ig:Activation> </ig:Activation> <ig:EditingCore AutoCRUD="False"> <Behaviors> <ig:CellEditing> <CellEditingClientEvents ExitedEditMode="WebDataGrid1_CellEditing_ExitedEditMode" /> </ig:CellEditing> <ig:RowAdding> <AddNewRowClientEvents ExitedEditMode="WebDataGrid1_RowAdding_ExitedEditMode" /> </ig:RowAdding> </Behaviors> </ig:EditingCore> <ig:Selection CellClickAction="Row" RowSelectType="Single"> </ig:Selection> <ig:RowSelectors> </ig:RowSelectors></Behaviors>
function WebDataGrid1_RowAdding_ExitedEditMode(sender, eventArgs) { __doPostBack('<%= SampleUpdatePanel.ClientID %>', ''); }
But, in this case, it generates a postback (I know it because put a breakpoint in Page_Load()) every time it exits of a cell (in The last row is used to insert or add), that's ok, but NOT enters in the following event:
protected void WebDataGrid1_RowAdding(object sender, RowAddingEventArgs e){//My code}
I need to enter into this event each time it leaves of a cell (not whole row) within the row to add (in The last row is used to insert or add). What is happened? Why in this case, not enter in the event WebDataGrid1_RowAdding()?Can you help me, please? Any suggestions?
Thanks.Geovanny Domínguez
Hello Vasya,
Just one more thing, please!. Now, I would like to do the same, but in the cells of row adding. Because, your suggest works perfect in the others cells, but doesn't in cells of row adding. May you help me?
Thanks.
Geovanny Domínguez.
I'm sorry for not replay. Yes, I been able to resolve my issue. You help me a lot.
Geovanny Domínguez
Hello Geovanny,
I am still following your case. Have you been able to resolve the issue? If you still have any questions or concerns I will be glad to help. Do not hesitate to ask if you need any additional assistance.
What I can suggest for your scenario is defining a global variable to use it as a flag for any changes made in the cell. Afterwards in the CellValueChanged handler set the value of the flag depending on whether any changes are made and finally in ExitingEditMode to check the value of the flag and do postback if necessary as such:
var changes; function WebDataGrid1_Editing_CellValueChanged(sender, eventArgs) { var oldValue = eventArgs.get_oldValue(); var newValue = eventArgs.get_cell().get_text(); if (oldValue === newValue) { changes =false; } else { changes =true; } } function WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs) { if (changes) { __doPostBack('<%= SampleUpdatePanel.ClientID %>', ''); } }
var changes;
function WebDataGrid1_Editing_CellValueChanged(sender, eventArgs)
{
var oldValue = eventArgs.get_oldValue();
var newValue = eventArgs.get_cell().get_text();
if (oldValue === newValue) {
changes =false;
else {
changes =true;
function
WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs)
if (changes) {
__doPostBack('<%= SampleUpdatePanel.ClientID %>', '');
Hope this helped. Do not hesitate to contact me if you have any additional questions regarding this matter.
Hello Vasya
At this point, all is fine, but now I need to validate in client-side if one cell was modified or not, in this way to prevent a postback in event fired after a cell has exited edit mode. I need to trigger a postback only when a cell was modified.
Could you help me, please?
I hope your response.