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

Can I access one cell to get column,,

5 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anoop
Top achievements
Rank 1
Anoop asked on 09 Feb 2011, 08:35 AM

I want to click on one cell in the grid view to get a whole column on another form related to one single cell,,

 

For example:

 

If I had a database which have products table and product details table,,

In my grid view I want to click on one product (cell) to get the details for that  product in separate form which contains another grid view.
the details will be column in another table in the database. 

 

Thanks in advance,,

5 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 09 Feb 2011, 10:23 AM
Hello Anoop,

There are several ways to get the cell value when you click on it which are demonstrated below

private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
    if (e.Row.Index > -1)
    {
        var cellValue = e.Value;
        // or
        var cellValue1 = this.radGridView1.CurrentCell.Value;
        // or
        var cellValue2 = e.Row.Cells["ColumnName"].Value;
    }
}

However, from you explanation of having a product and product details table, you may want to explore using a Hierarchy Grid View to display the data in a hierarcical way. You can find out more about this type of view here

Hope that helps
Richard
0
Anoop
Top achievements
Rank 1
answered on 09 Feb 2011, 11:26 AM

Thanks a lot for your reply,,



one more question,,
can I get a row instead of column,,


thanks

0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 09 Feb 2011, 11:30 AM
Hello Anoop,

As per my post above, you need to use the GridViewCellEventArgs not System.EventAergs
private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)

This will give you all the row, column and cell information that you will need.
Hope that helps but let me know if you need further information
Richard
0
Anoop
Top achievements
Rank 1
answered on 09 Feb 2011, 11:33 AM
thaaaaaaaaanks Richard
0
Richard Slade
Top achievements
Rank 2
answered on 09 Feb 2011, 11:43 AM
No problem. Please remember to mark as answer and if you need more help, just let me know
Richard
Tags
GridView
Asked by
Anoop
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Anoop
Top achievements
Rank 1
Share this question
or