This is a migrated thread and some comments may be shown as answers.

Getting GridViewCheckBoxColumn Values

3 Answers 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 10 May 2010, 11:12 AM

Hi,

I have a grid which I populate using the below method

 

this.gvSheet.MasterGridViewTemplate.LoadFrom(q.ExecuteReader());

            for (int i = 0; i < gvSheet.MasterGridViewTemplate.Columns.Count; i++)

            {

                this.gvSheet.MasterGridViewTemplate.Columns[i].Width = 150;

                this.gvSheet.MasterGridViewTemplate.Columns[i].WrapText = false;

            }

 

I then add three checkbox columns using the below

GridViewCheckBoxColumn cb1 = new GridViewCheckBoxColumn();

            cb1.UniqueName = "ucb1";

            cb1.HeaderText = cb1";

            cb1.Width = 150;

            cb1.WrapText = false;

            cb1.ReadOnly = false;

            this

 

.gvSheet.Columns.Add(cb1);

 

 

            this.gvSheet.Columns.Add(cb2);

 

 

            this.gvSheet.Columns.Add(cb3);

 

 

 

 

I’m trying to get the values of these three GridViewCheckBoxColumn on the gvSheet_ValueChanged(

I’ve tried

gvSheet.CurrentRow.Cells["ucb1"].Value.ToString() and gvSheet.CurrentRow.Cells["cb1"].Value.ToString() and I get nothing back.

 

What I’m trying to achieve is if I select cb1 and cb2 column I should get true, true, false returned. I have some business logic which works off the values of these three check boxes.

 

Any help or pointers would be great.

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 10 May 2010, 03:37 PM
Hi Karl,

Thank you for contacting us.

The ValueChanged event fires when the editor changes its value. At this stage it is not yet saved in the data layer. You have to handle the CellValueChanged event instead. However, this event will fire when changing the row. You can save the value on ValueChanged event by calling RadGridView.EndEdit method. Here is a sample:

void radGridView1_ValueChanged(object sender, EventArgs e)
{
    RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
    if (editor != null)
    {
        this.radGridView1.EndEdit();
    }
}

I hope this helps. If you need further assistance, don't hesitate to write back.

Best wishes,
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.
0
Karl
Top achievements
Rank 1
answered on 10 May 2010, 04:22 PM
Hi,

Thanks for getting back to me, I've tried putting this in to the CellValueChanged

RadMessageBox

 

.Show(gvSheet.CurrentRow.Cells[9].Value.ToString() + "\n" + gvSheet.CurrentRow.Cells[10].Value.ToString() + "\n" + gvSheet.CurrentRow.Cells[11].Value.ToString());

It seems very slow to respond if any response at all.

Do you have any further examples/documents of your explanation?

Thanks

 

0
Karl
Top achievements
Rank 1
answered on 10 May 2010, 04:36 PM
Sorry, Ignore my last post.
Tags
GridView
Asked by
Karl
Top achievements
Rank 1
Answers by
Jack
Telerik team
Karl
Top achievements
Rank 1
Share this question
or