Solved

Get Selected Item wpf datagrid

Posted on 2011-03-11
4
1,278 Views
Last Modified: 2012-05-11
WPF This should be really simple but I just can't find it. New to WPF so sorry about this.
I have a datagrid and just want to click on a cell and either show its contents in a text box or popup a messagebox with the value.
Thought it should be selectedvalue or selecteditem or something like that but have had no luck sofar.

Thanks
Cnat even find WPF zone to put this question in
0
Comment
Question by:Eamon
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Sudhakar Pulivarthi earned 500 total points
ID: 35108248
0
 
LVL 1

Author Comment

by:Eamon
ID: 35109813
This is how the dataGridd is filled

cmd.ExecuteNonQuery();
SqlDataAdapter daPopGRN = new SqlDataAdapter(cmd);

DataSet dsPopGRN = new DataSet();
daPopGRN.Fill(dsPopGRN, "GRN");

dgGrn.ItemsSource = dsPopGRN.Tables[0].DefaultView;
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 35110378
Hi Eamon,

Here is how a solution is provided to your requirement.
http://stackoverflow.com/questions/3774140/wpf-datagrid-datatable-large-number-of-rows
0
 
LVL 1

Author Closing Comment

by:Eamon
ID: 35213587
I ended up using this.

int i = dgGrn.Items.IndexOf(dgGrn.SelectedItem);
                var rowData = dgGrn.Items[i] as DataRowView;
                ret = rowData[ColName].ToString();
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question