Winform RadGridview data binding events

14 posts, 0 answers
  1. Sandeep
    Sandeep avatar
    6 posts
    Member since:
    Jul 2008

    Posted 30 Jul 2008 Link to this post

    hi,
    i am new to telerik controls and winforms. I am using RadGridView, i want to do some calculations on each item data bound, is there any item data bound event i can capture and do some operation before binding it to gridview.

    Thanks,
    Sandeep
  2. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 01 Aug 2008 Link to this post

    Hi Sandeep,

    RadGridView does not implement ItemDataBound event. However, should you want to do calculations with the bound data, you can use the Expressions feature demonstrated in the Quick-Start Framework application (a.k.a. Examples), section RadGridView >> Expressions.

    If you have additional questions, feel free to contact me.

    Kind regards,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Sandeep
    Sandeep avatar
    6 posts
    Member since:
    Jul 2008

    Posted 01 Aug 2008 Link to this post

    Hi Nikolay,
    Thanks for the reply.
    i have business object Client, which has contactList. I created ClientList, which i want to bind with RadGridView as shown below. In the shown image there is text box, which should provide instant search. Is there any Telerik control, using which i can implement this functionality. Contact List showld be shown as dropdown list. This is an windows application.
    If you have sample code to demonstrate this applicatio, it would be great.


    Type Name to search client
    CheckBox Client Contact
     
    Sandy ContatcDropDownList
     
    Andy ContatcDropDownList


    Thanks,
    Sandy


  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 04 Aug 2008 Link to this post

    Hi Sandeep,

    You can use the filtering operation of RadGridView for this scenario:

    private ParameterValuePair parameter = null
    private void searchTextBox_TextChanged(object sender, EventArgs e) 
        if (parameter == null
        { 
            this.radGridView1.EnableFiltering = true
            this.radGridView1.MasterGridViewTemplate.ShowFilteringRow = false
     
            parameter = new ParameterValuePair(GridFilterCellElement.ParameterName, searchTextBox.Text); 
            FilterExpression filter = new FilterExpression(FilterExpression.BinaryOperation.AND, 
                GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName); 
            filter.Parameters.Add(parameter); 
     
            this.radGridView1.Columns["City"].Filter = filter; 
        } 
        else 
        { 
            parameter.Value = searchTextBox.Text; 
        } 

    I hope this helps.
    Don't hesitate to contact us if you have other questions.

    Sincerely yours,
    Julian Benkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Sandeep
    Sandeep avatar
    6 posts
    Member since:
    Jul 2008

    Posted 08 Aug 2008 Link to this post

    hi,
    Thanks for the reply. I got stuck at one more issue. i added GridViewCheckBoxColumn in the grid to and not binding any data column to this. i want to get checked property of the checkbox inside the column. how to retrive checked property of checkbox. i am trying to get this on ValueChanged event. here is the code i am using. is it possible to get true/ false status of checkbox.


            private void radGridView1_ValueChanged(object sender, EventArgs e)
            {
                GridDataCellElement cell = sender as GridDataCellElement;
                Telerik.WinControls.RadElement rootElement =  cell.ElementTree.RootElement;
                GridViewColumn gridViewColumn = cell.ColumnInfo;
                 object objectValue = cell.Value;
               
               
                 DataRowView drvHosts =  (DataRowView) cell.RowInfo.DataBoundItem;
                 string clientName = drvHosts.Row[0].ToString();          
                
            }

    Thanks & Regards,
    Sandeep
  6. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 11 Aug 2008 Link to this post

    Hi Sandeep,

    You can use following code snippet to achieve your purpose:

    private void radGridView1_ValueChanged(object sender, EventArgs e) 
        GridDataCellElement cell = sender as GridDataCellElement; 
        radGridView1.EndEdit(); 
     
        if (cell is GridCheckBoxCellElement) 
        { 
            MessageBox.Show(string.Format("The new value of checkbox is: {0}", (bool)cell.Value)); 
        } 

    Don't hesitate to contact us if you have other questions.

    All the best,
    Julian Benkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Elizabeth
    Elizabeth avatar
    8 posts
    Member since:
    Sep 2008

    Posted 22 Jul 2009 Link to this post

    Hi -

    I before upgrading to the latest version  2009.2.9.701, I was able to detect a grid checkbox change using ValueChanged event.  I was able to cast the sender to a griddatacellelement to get column info.  Now, with the latest release, the sender for my checkbox columns cannot be cast  this type, and all of my code is now being bypassed.  I didn't see this a "breaking change", but now I suspect I need to trap a differnent event?  Thanks in advance for your reply.

    private

     

    void grdOpenTxn_ValueChanged(object sender, EventArgs e)

     

    {

     

    GridDataCellElement cell = sender as GridDataCellElement; <---This now comes back as null, it used to give data.

     

     

    if (cell != null && ((GridViewDataColumn)cell.ColumnInfo).FieldName == "Selected")

     

    {

     

    if (grdOpenTxn.ActiveEditor is RadCheckBoxEditor)

     

  8. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 23 Jul 2009 Link to this post

    Hi Elizabeth,

    In our latest release we did a major revamp of our editors system. This caused some changes. The ValueChanged event fires when the editor value is changed, in this case the sender argument is the editor itself. I modified your code to reflect the changes in our API. Here is the code:

    void grdOpenTxn_ValueChanged(object sender, EventArgs e) 
        RadCheckBoxEditor editor = sender as RadCheckBoxEditor; 
        if (editor != null && ((GridViewDataColumn)this.grdOpenTxn.CurrentCell.ColumnInfo).FieldName == "Selected"
        { 
            //... 
        } 

    I hope this helps. You can find more about events related to editors in RadGridView in the following help article. Should you have more questions, I will be glad to help.

    Regards,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Bryan Ruddy
    Bryan Ruddy avatar
    2 posts
    Member since:
    Dec 2009

    Posted 30 Jul 2010 Link to this post

    I am trying to find the event that is executed whenever a peice of data is modified in a RadGridView.  Subsequently I am trying to update the data source but cannot find the appropriate event for this.
  10. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 03 Aug 2010 Link to this post

    Hello Bryan Ruddy,

    Thank you for this question. Usually grids in WinForms applications commit their changes when the form closes or when an update button is pressed. Nevertheless, RadGridView supports various events which can be used to track that something has changed:

    - The CellValueChanged event fires when a cell changes its value.
    - The RowValidated event fires when changing the current row. You can use the IsModified property to track whether there is a cell which contains changes:

    void radGridView1_RowValidated(object sender, RowValidatedEventArgs e)
    {
        if (e.Row.IsModified)
        {
            // ...
        }
    }

    - The UserAddedRow and UserDeletedRow events fire when a row is added or removed by using the UI

    I hope this helps.

     

    Greetings,
    Jack
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. SATISH
    SATISH avatar
    2 posts
    Member since:
    Oct 2014

    Posted 17 Oct 2014 Link to this post

    hello ,
    I want following gridview link  functionality in windiws from gridview
    http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx
  12. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3204 posts

    Posted 21 Oct 2014 Link to this post

    Hello Satish,

    Thank you for writing.

    Similar functionality is available in our Demo application >> GridView >> Rows >> Row Details example. It demonstrates a sample approach how to construct a detailed row look for your grid. Feel free to modify it on a way which suits your requirement best.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  13. SATISH
    SATISH avatar
    2 posts
    Member since:
    Oct 2014

    Posted 25 Nov 2014 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi 
    i am doing radgridview for winforms  insert, update, delete  but after  updating record my grid is not taking updated value ,but in my datatable it is showing updated record  here is following code i am using



     string sQuery = "select id, ans1 as Answer1,ans2 as Answer2,ans3 as Answer3,ans4 as Answer4 from tblAnswer";
                    oDs = null;
                    oCon = new SqlConnection(conStr);
                    oCon.Open();
                    SqlCommand cmd = new SqlCommand(sQuery, oCon);
                    radTest.DataSource = null;
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    radTest.DataSource = dt;






  14. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3204 posts

    Posted 28 Nov 2014 Link to this post

    Hello Satish,

    Thank you for writing back.

    RadGridView is capable of fetching bindable properties and data. However, one important issue must be noted: during the data binding process, the grid extracts the data from the data source, but for any later changes in the data source, RadGridView should be notified.

    According to the provided code snippet, you fill a DataTable with the current data in the database. Afterwards, the RadGridView.DataSource property is set to this DataTable. When a certain modification in the database is performed, it is not reflected to the DataTable. Hence, the RadGridView is not notified for any changes. You can fill the SqlDataAdapter with the new data and rebind the RadGridView ​in order to obtain the actual data.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top