.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Datagrid: How to select a specific row by program?

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :WPF

How to select a specific row in the Datagrid (in WPF) programmatically? (like datagridview1.Rows(index).Selected = True in Windows form)?

I wants to select first row programmatically by defualt after it populating all the records. I treid DataGrid1.Selectedcell and all similar methods, but not able to get what I need. It looks that Data grid in WPF does not have anything related to Row while DataGrid is in Windows form have many things related to Row



Dreaming a world without any war in anywhere

View Complete Post

More Related Resource Links

Select only one radio button in a datagrid


I have been frantically searching for help to select only one radio button in datagrid and deselect the other when a new button is clicked.

I do not want to use javascript. Can someone help me on this?

Sorting a specific DataGridColumn in wpf DataGrid

Hi! I have a WPF DataGrid that has several DataGridColumns, one of these columns is bound to a Property that is an abstract class. Like this:    public class Cat { public AbstractCatType Type { get; set; } } public class AbstractCatTypeToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is NiceCatType) { return "Nice"; } if (value is BadCatType) { return "Bad"; } return "unknown"; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new System.NotImplementedException(); } } When i click the column header to sort this column I get (not very suprising) an exception System.InvalidOperationException was unhandled Message="Failed to compare two elements in the array." I would like the column to get sorted on the string values it contains (Bad, Nice) but how can I do that? I would prefer to specify a Comparer class for that column or if I could make it forget about the property that it is bound to and sort the strings written in the column. I would prefer not to have to create specific comparers for all of my columns and I have no other SortMemberPath to redirect the sorti

Conditional insert: If select return rows, insert rows to table otherwise insert specific row indica

This is what I have

Insert into ReportDetail( Partcipantid, Reportid)  

select distinct ParticipantID , 9 from OpenCredit

      except select ParticipantID, 9 from StoreCredit where Closed = 0

 Issue is that when above select statement returns no row, it seems like no record is

Datagrid error Select Command


I am getting with this code so I assume what I am doing won't work

Here is the Code from the datagrid

SelectCommand="SELECT * FROM [location]WHERE LocationID = <%# getUserLocations.ToString() %> ORDER BY LocationName"></asp:SqlDataSource>

It is obvious what I am trying to do. Apprciate any suggestions



select specific field from DB


how to select  a specific field data from DB

using  HQL   ,  working with Nhibernate    with C#.net

How to disable WPF Toolkit DataGrid cell RenderTransform on Select



I have customized wpf toolkit datagrid in my project. When selected datagrid cell are RenderTransform.ScaleX and ScaleY transformed. I want to disable this .

Any hint. I couldn't find anything googling.

Thank you in advance.


Best regards, Ana Danilovic

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Use Jquery with repeater, gridview, datagrid

Before we talk about jquery inside any itemtemplate (repeater, gridview, datagrid), we need to understand the basic use of jquery functions

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

Using the WPF Toolkit DataGrid

WPF comes with a large number of built in controls, but from the beginning it has lacked something that many application developers find extremely important - a DataGrid. You can use the ListView to create something approximating a DataGrid

Program for Format Conversion of An Image

.NET provides extensive support for image conversion. Any image can be processed from one format to another. Most common formats to which .NET have support for are .BMP, .EMF, .GIF, .ICO, .JPG, .PNG, .TIF and .WMF.

A datagrid control that can be personalized... anyone??


Hello all,

I need a datagrid control that has following features, besides other regular stuff like paging, sorting, filtering, etc:

The user should be able to -

1. Select columns to view

2. Select column Sequence

3. Select default sort column

4. Store the setting (as a view) and use it on next visit.

5. llow multiple such views to be stored for a user for future use.

All these settings should be saved and when the user comes back he gets the same settings.

Really appreciate your time and would love to get any ideas.


- Zen

Select value in gridview


Hi, I am new to gridview. I want to make a gridview. Its row when selected should direct me to a specific .aspx page.Each row should direct to a different page. Should I use querystrings for this? Please suggest. Regards, ap.

Button specific code


I have 2 submit buttons on my page. Right now, the only way to run the code behind with razor is to to If(IsPost). Since I have 2 buttons, how would I destinguish between the two in post? Is there a way to request a button that sent a post request?  

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend