Breaking News
Loading...
Tuesday 10 June 2014

How to get column value from the selected row in data grid in wpf c#.net



Data grid is a control for display the data in tabular format in our application. In data grid when u select any row then for getting this rows unique id write code like :
Ex : here we will take ‘dgcustomer’ as data grid with following column name (Id,Name,RollNumber,Pass)
                       
string strid = "";
                        DataRowView rowview = dgcustomer.SelectedItem as DataRowView;
              strid = rowview.Row["Id"].ToString();
MessageBox.Show("ID : " + strid);

4 comments:

  1. Showing error at line
    strid = rowview.Row["Id"].ToString();
    while execution :((

    ReplyDelete
  2. Hello,
    Can you say me what error you get ?
    And {{strid = rowview.Row["Id"].ToString();}}
    here "Id" is your column name.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete

Thanks for comment

 
Toggle Footer