We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Access Data source on server side.

 <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True"  IsResponsive="true" Width="400" >
            <Columns>
                <ej:Column Type="checkbox" Width="10" Field="isSelected"  ></ej:Column>
                <ej:Column Field="code" HeaderText="Code" IsPrimaryKey="True" TextAlign="Right" Width="15" />
                <ej:Column Field="name" HeaderText="Airline " TextAlign="Right" Width="35" Priority="4" />
                <ej:Column Type="checkbox" Width="10" Field="isMaster"  ></ej:Column>
            </Columns>
        </ej:Grid>
  <asp:Button ID="btnSave" OnClick="btnSave_Click" runat="server" Text="Submit" />

How can get the datasource value, with the changed check box values on the asp:button click ?

3 Replies

MP Manivannan Padmanaban Syncfusion Team May 21, 2019 08:58 AM UTC

Hi Krishnakumar, 

Thanks for contacting Syncfusion support. We are happy to assist you. 

Query: How can get the datasource value, with the changed check box values on the asp:button click ?  

From the above query, we are able to understand that you want to get the checkbox changes value in the dataSource on asp button click. We have achieved your requirement by using the OnServerBatchEditRow event. Every time checkbox value change the OnServerBatchEditRow event will trigger and we have to update the changes. Refer the below code example, 


  <asp:Button ID="btnSave" OnClick="btnSave_Click" runat="server" Text="Submit" /> 
 
 
    <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" IsResponsive="true" OnServerBatchEditRow="OnServer_Batcheditrow" Width="400"> 
        <EditSettings AllowEditing="true" EditMode="Batch"></EditSettings> 
        <Columns> 
            <ej:Column Type="checkbox" Width="10" Field="isSelected"></ej:Column> 
            <ej:Column Field="code" HeaderText="Code" IsPrimaryKey="True" TextAlign="Right" Width="15" /> 
            <ej:Column Field="name" HeaderText="Airline " TextAlign="Right" Width="35" Priority="4" /> 
        </Columns> 
    </ej:Grid> 



  protected void OnServer_Batcheditrow(object sender, GridEventArgs e) 
        { 
 
            ArrayList changed = ((ArrayList)((Dictionary<String, Object>)e.Arguments["batchChanges"])["changed"]); 
            if (changed.Count > 0) 
                GridAction("change", changed, e); 
 
             
 
        } 
 
        protected void GridAction(string eventType, ArrayList changed, Syncfusion.JavaScript.Web.GridEventArgs e) 
        { 
 
            if (eventType == "change") 
            { 
                Orders value = new Orders(); 
                for (var i = 0; i < changed.Count; i++) 
                { 
                    Dictionary<string, object> KeyVal = changed[i] as Dictionary<string, object>; 
                    foreach (KeyValuePair<string, object> keyval in KeyVal) 
                    { 
                        if (keyval.Key == "code") 
                            value.code = Convert.ToInt32(keyval.Value); 
                        if (keyval.Key == "name") 
                            value.name = Convert.ToString(keyval.Value); 
                        if (keyval.Key == "isSelected") 
                            value.isSelected = Convert.ToBoolean(keyval.Value); 
                    } 
                } 
 
                Orders update = order.Where(ord => ord.code == value.code).FirstOrDefault(); 
                update.isSelected = value.isSelected; // update the changed checkbox value. 
                 
            } 
 
        } 
 
 
        protected void btnSave_Click(object sender, EventArgs e) 
        { 
             
            var dataSource = this.FlatGrid.DataSource; // get the changed checkbox dataSource value here. 
 
        } 


Output: 

 

For your convenience we have created the sample, refer the below link. 

Note: And also, from the shared code example we could see that you have used more than one type “checkbox” column. We have to use only one type checkbox column in the column definition otherwise it will lead to conflict. 

Please get back to us, if you need further assistance. We will be happy to assist you. 

Regards, 
Manivannan Padmanaban. 



TH thedisaster replied to Krishnakumar October 17, 2019 01:53 AM UTC

 
           
               
               
               
               
           

       

 

How can get the datasource value, with the changed check box values on the asp:button click ?  https://scrabblewordfinder.vip/

I'm a beginner with c# / asp.net and I'm trying to get entity framework code-first working with mySQL usign a variety of tutorials.. I've managed to get through loads of issue https://www.applock.ooo/s but this one is killing me:

When I try to migrate the database I receive the following error: MySql.Data.MySqlClient. https://www.7zip.vip/ MySqlException (0x80004005): Unknown column 'no' in 'field list'

Based on the SQL generated:

set @columnType := (select case lower(IS_NULLABLE) when `no` then CONCAT(column_type, ` ` , `not null `)  when `yes` then column_type end from information_schema.columns where table_name = `Student` and column_name = `FirstMidName` );

mySQL doesn't know WTF the ` character is.. This should be either ' or " -- Is there any way to tell the migrator that this should be the case?

P.S. In my Migration config I have the following code:

SetSqlGenerator("MySql.Data.MySqlClient", new MySqlMigrationSqlGenerator());


MP Manivannan Padmanaban Syncfusion Team October 17, 2019 12:51 PM UTC

Hi Thedisaster, 

Thanks for the update. 

The shared query is not related to our Syncfusion Grid component, but you can refer the below general link to resolve the reported issue. 

And kindly get back to us, if you have any query related with our Syncfusion controls. 

Regards, 
Manivannan Padmanaban. 


Loader.
Live Chat Icon For mobile
Up arrow icon