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


Top 5 Contributors of the Month
Shivakumaran
Post New Web Links

I declared a datagrid in xaml, now I want to add main columns in this datagrid at runtime through vi

Posted By:      Posted Date: November 03, 2010    Points: 0   Category :WPF
 

I have declared datagrid in xaml like this ;

<DataGrid AutoGenerateColumns="False" ........

 

and want to access this datagrid in viewmodel to add columns with headers to this datagrid at runtime. Actually i want to declare any number of columns in grid which i read from database table at execution time. If anybody could help me in this regard....




View Complete Post


More Related Resource Links

How to bind datagrid columns to external (main) datacontext?

  

Hi

I have a datagrid and his columns binds well to its collection data. But when I add a new data column (ie. DataGridTextColumn or DataGridComboBoxColumn) and Bind to the main Data Context of window the data are missing (dont show)

In this sample, The last two columns of DataGrid dont bind to the main data.

<Window x:Class="MainWindow"

 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 xmlns:app="clr-namespace:DGComboBox.myData"

 Title

Dynamically Assign Datagrid Column Binding from XAML

  

I am trying to build a generic user control that will serve as a quick list maintenance screen.

I have a base ViewModel that has two string properties IDColumnName and DisplayColumnName and then a collection of objects to be edited.  Inherited view models will be created for each object type that needs to be maintained.  The usercontrols datacontext is set to the viewmodel.

What I want to do is have the datagrid, who's itemssource is bound to the collection of objects in the viewmodel, have one column and have that one column bound to the property specified in the DisplayColumnName property of the viewmodel, and I'd like to do it all in XAML.  I've got the datagrids rowdetailstemplate being dynamically determined based on the object type but am struggling with dynamically setting which property the one column displays.


Sort WPF Datagrid using multiple columns

  

Hi,

Is it possible to sort a WPF datagrid using more than one column ?

Thanks

Vijay


How add and bind DataGrid columns programmatically ??

  

Hi all,

 

How are you ??

 

please i need to know how to add and bind DataGrid columns programmatically ( NOT IN XAML),

i was using  this code in windowsForms i need equivalent for it in WPF please :

            DataGridViewColumn column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "DataPropertyName";
            column.Name = "columnName";
            column.DisplayIndex = 1;
            column.Width = 150;
            column.ReadOnly = true;
            column.Visible = true;
            Datagrid1.Columns.Add(column);

 

help me please , Thanks a lot .....


 

 

 

 

 


how to hide a column in a datagrid but autogenerated columns = "True"?

  

Hi,

  Anybody help me please!!! I've 3 datasets named ds1, ds2, ds3. Then i merged that 3 datasets into 1 datatable named dt1. Now, my question is, i want to hide some datacolumns its present in an ds2. How????? Below i attached my code,

string

 

connectionString = "provider=MSDAORA;data source=proact;user id=mah;password=mah";

 

OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);

 

Datagrid with varying columns

  

I am upgrading a classic asp page, the page uses response.write to make a table, as soon as a null value comes up for a month the columns of the grid then stop.  The sql is below

SELECT sName, Strategy, 
Sum(case when Month([Date])=1 then Rtn else null end) as Jan, 
Sum(case when Month([Date])=2 then Rtn else null end) as Feb, 
Sum(case when Month([Date])=3 then Rtn else null end) as Mar, 
Sum(case when Month([Date])=4 then Rtn else null end) as Apr, 
Sum(case when Month([Date])=5 then Rtn else null end) as May, 
Sum(case when Month([Date])=6 then Rtn else null end) as Jun, 
Sum(case when Month([Date])=7 then Rtn else null end) as Jul, 
Sum(case when Month([Date])=8 then Rtn else null end) as Aug, 
Sum(case when Month([Date])=9 then Rtn else null end) as Sep, 
Sum(case when Month([Date])=10 then Rtn else null end) as Oct, 
Sum(case when Month([Date])=11 then Rtn else null end) as Nov, 
Sum(case when Month([Date])=12 then Rtn else null end) as Dec  
FROM Chess

If this is run in oct i only have data from jan -0ct , how do i not display nov and dec so that its dynamic?


How to sort the detail DataGrid in a Master-Detail page using XAML?

  

I have created a Master-Detail WPF on a Entity FrameWork object.

...
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
...
>

<Page.Resources>
     <CollectionViewSource x:Key="MasterViewSource" />
     <CollectionViewSource x:Key="DetailViewSource"
          Source="{Binding Source={StaticResource MasterViewSource}, Path=MasterDetailRecords}" />

I am attempting to sort the details by the "SortValue" property in the details table.

When I try the following an error is generated at execution:

<Page.Resources>
     <CollectionViewSource x:Key="MasterViewSource" />
     <CollectionViewSource x:Key="DetailViewSource"
          Source="{Binding Source={StaticResource MasterViewSource}, Path=MasterDetailRecords}">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="SortValue"/>
 &n

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

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.

Cheers

- Zen


DataGrid

  

Dropdownlist Show the all PatientName and save the PatientID in the database and in datagrid showing the PatientID my requirement is that the PatientName show in DataGrid.

how to do ? 


Cutting Edge: Moving DataGrid Rows Up and Down

  

Imagine opening your Inbox one morning and finding a message that reads "Dear Mr. DataGrid, I urgently need an ASP.NET DataGrid that lets my users move rows on the client. You're my last hope. Will you please help me?"

Dino Esposito

MSDN Magazine March 2005


GridView: Move Over DataGrid, There's a New Grid in Town!

  

When incorporating the ASP.NET DataGrid control into your Web apps, common operations such as paging, sorting, editing, and deleting data require more effort than you might like to expend. But all that is about to change. The GridView control--the successor to the DataGrid-- extends the DataGrid's functionality it in a number of ways. First, it fully supports data source components and can automatically handle data operations, such as paging, sorting, and editing, as long as its bound data source object supports these capabilities. In addition, the GridView control offers some functional improvements over the DataGrid. Here DataGrid expert Dino Esposito introduces the GridView and explains all its long-awaited features.

Dino Esposito

MSDN Magazine August 2004


Categories: 
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