how to get row value from database?

2 posts, 0 answers
  1. Aldy
    Aldy avatar
    8 posts
    Member since:
    Sep 2015

    Posted 10 Nov 2015 Link to this post

    I want to get row value after i click a cell. I try using SelectionChanged and follow so many Q&A in many forum and still can't do this. maybe if you guys can give me an example for this, maybe after click a cell it will give message about every value in that row?

    here is my whole code, i hope telerik team can help me.


            <StackPanel x:Name="xPanel">
                <telerik:RadGridView x:Name="dataGrid"
                                     ShowGroupPanel ="False"
                                     CanUserReorderColumns ="False"
                        <telerik:GridViewDataColumn Header="idx"
                                                    DataMemberBinding="{Binding idx}" />
                        <telerik:GridViewDataColumn Header="tag"
                                                    DataMemberBinding="{Binding tag}" />
                        <telerik:GridViewDataColumn Header="value"
                                                    DataMemberBinding="{Binding value}" />
                <telerik:RadButton Content="Update" Height="30" Click="RadButton_Click" />


    namespace Setting
        public partial class MainWindow : Window
            ScimoreDataAdapter dataAdp;
            DataSet ds;
            public MainWindow()
                string dbInstanceName = "C:\\Users\\Abc\\Documents\\Visual Studio 2010\\Projects\\Setting\\Setting\\configdb";
                ScimoreEmbedded em = new ScimoreEmbedded();
                    using (ScimoreConnection cn = em.CreateConnection())
                        string query = "select idx,tag,value from";
                        dataAdp = new ScimoreDataAdapter(query, cn);
                        DataTable dataTable = new DataTable("info");
                        ds = new System.Data.DataSet();
                        dataAdp.Fill(ds, "info");
                        dataGrid.ItemsSource = ds.Tables[0];
                        dataAdp.Update(ds, "info");
                catch (Exception)
            private void RadButton_Click(object sender, RoutedEventArgs e)
            private void dataGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
                //System.Data.DataRowView CurrentSelected = ((System.Data.DataRowView)dataGrid.SelectedItem);

  2. Dilyan Traykov
    Dilyan Traykov avatar
    337 posts

    Posted 13 Nov 2015 Link to this post

    Hello Aldy,

    You can have a look at the Selection Events page of our documentation. You have correctly approached the Selection Changed event, you just need to combine it with the RadGridView SelectedItem property.
    I've attached a sample project showing how to achieve the desired behaviour as I could not use your data source.

    Here is the important part:

    public MainWindow()
        this.radGridView.ItemsSource = EmployeeService.GetEmployees(); // change it with your data source
        this.radGridView.SelectionChanged += this.SelectionChanged;
    private void SelectionChanged(object sender, SelectionChangeEventArgs e)
        var employee = this.radGridView.SelectedItem as Employee;
        MessageBox.Show(string.Format("{0} {1}, {2}", employee.FirstName, employee.LastName, employee.IsMarried ? "Married" : "Not Married")); // modify as you like

    Let me know if this helps.

    Dilyan Traykov
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top