.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

Changing crid cell content at runtime

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

In a cell in a grid, I have a TreeView. When the parsing of the data behind the treeview yields an error, I would like to replace the treeview with a textblock with information on the error details.

I'm thinking about using a datatemplateselector, but I can't figure out how, or if this is the best approach. Any suggestions?

Alternatively I will place a ContentControl in the grid cell and populate it with the correct content from the code behind file, I just think there could be a more elegant solution in pure XAML.

View Complete Post

More Related Resource Links

changing the content of website runtime

say i have a table in my website that contain <tr>  and <td> and "hello good morning" is wriiten over there. how can change the content of my website to "hello good night" on a click of button or using any other way of doing  this like yahoo and other popular website did.

Programmatically Changing the Profile Provider at Runtime


Dear All

I'm using one application but have multiple providers in my web.config for memberships, roles and profiles to allow my application to be used by different groups of users who need to connect to different databases.

This means I'm having to change the membership, role and profile providers on-the-fly in my code-behind files. So far I've taken care of the membership and roles a bit like this:

Dim RolePV As RoleProvider = Roles.Providers(GetSettingFromFile("Provider"))

However, I'm having trouble finding out how to do the same sort of thing for Profiles. I've looked at ProfileProvider and ProfileManager but I can't work it out how to access my the profile property that I've created in my web.config file called "ScreenSize". Normally you would just write Profile.ScreenSize to read or write to the property.

Please can you help me to understand how I access the profile property called ScreenSize by dynamically setting the profile provider first?

I'd be very grateful for any help or advice.

Many thanks



Changing title o sitemapnode at runtime from code behind c#

Hi guys ! I have a site map on my project and I have section which get values from sql database and it changes according to querystring Id value. In my sitemap the title of the page is everytime same. but I want tpo change it at runtime. I am using multiple sitemaps and My sitemap is not the default one. its name is rootSitemap. I tried some code which I got from msdn but it seems doesn't work for me; protected void Page_Load(object sender, EventArgs e) { SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(this.ExpandForumPaths); } private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e) { // The current node represents a Post page in a bulletin board forum. // Clone the current node and all of its relevant parents. This // returns a site map node that a developer can then // walk, modifying each node.Url property in turn. // Since the cloned nodes are separate from the underlying // site navigation structure, the fixups that are made do not // effect the overall site navigation structure. SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true); SiteMapNode tempNode = currentNode; tempNode.Url = tempNode.Url + "?TransferType=" + Request.QueryString[0].ToString(); tempNode.Title = "My Transfer Desc - " + Request

Changing the content type of a document

Hi everybody, Can we change the content type of a document ? For example, I have a custom content type 'A' that inherits from the default document content type. If I upload a document (on behalf of the windows explorer) and the default document content type is assigned, can I change it to the content type 'A' after ? Thanks in advance.Psyllos

ContentControl's ToolTip - issues changing Content

Hi all,   I'm having a few issues changing the Content of a ContentControl.   I have a collection of MyClass. One of these at a time has a property IsSpecial set to true. I loop through the collection, find which one it is, and set my ContentControl's Content to the "special" MyClass. Later, a different MyClass becomes special (and the older one's IsSpecial is set to false). I then loop through, and reset the Content to the new MyClass. The problem I have is nothing seems to be updating/changing - the DataTemplate is showing the data from the previous MyClass. Changing the Content from one object to another should work, right?   EDIT: Further testing shows that the Content IS changing, but the ContentControl's Tooltip is NOT. The tooltip is part of my DataTemplate.

Changing Datagrid Cell foreground colour depending on previous value



I have a datagrid bound to a observable collection and a background thread is regularly updating the collection when an event is fired.( subscribed to a market data service) . I need to change the foreground of the cell value if (Previousvalue > NewValue) . I guess I need a conveter but how can I get access to the previous value ? Or is there a smarter way to do this. Performace is a concern as well.

Thanks v much.


WPF: how to change the ListView cell template if the content is too long, it will display as Charact


We have used the GridView inside the ListView. We fix the column width (see the following link):


if the content is too long in one cell (since we fix the column width), we want it display as CharacterEllipsis at the end

just like the TextBlock we can define TextTrimming="CharacterEllipsis"

how can we achive it?


we have used the ListViewItemStyle as following, can we modify the <GridViewRowPresenter  /> section to achive it?

  <!--ItemContainerStyle with the Trigger for selection x:Key="ListViewItemStyle"-->
  <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
   <Setter Property="Background" Value="Transparent"/>
   <Setter Property="HorizontalContentAlignment" Value="Center"/>
   <Setter Property="VerticalContentAlignment" Value="Center"/>
   <Setter Property="Foreground" Value="Black"/>
   <Setter Property="Margin" Value="5,0,5,0&q

changing Asp.net Gridview's cell from Label to edit mode in code behined file


 Hi all,

In my asp.net application i'm using gridview to which i'm binding data dynamically by writing a select query in code behined file (all column's are autogenerated) now i want to change gridview cell to edit mode from label to textbox or dropdown on clicking of gridview's cell.How can i achive this in code behined file.

thanks in advance

Changing the address in app.config at runtime ..AN ISSUE..HELP neede..

hi wcf champs.,

hmm...I have a problem..and seriously need a solution to get things done well..!!

Have developed a wcf Upload application,the wcf service is hosted on IIS..now,the endpoint address at the server is exposed at client(in app.config).If further the server ip changes to some other..then the address at the client must be changed..!right..ya I did something to handle this but ,its another problem..!!.

Let me say what i have done and why does that give a problem..


*.*.The server ip is stored in a xml file.When the application runs,it picks up the server ip and changes it in Client.exe.config...

*.And if there is EndpointotFound exception at the client,it asks the admin to check the ip of the server.

*.The admin checks it and if the server ip is changed,the admin changes the ip in the xml file (where server ip is stored).

now let me know.."IS THIS A RIGHT APPROACH TO SOLVE MY PROBLEM" ..But then there is a problem!!let me share that with u..


*.The ip that is picked from  xml and placed in Client.exe.config.

Changing fonts at runtime


Is it possible to change a font at runtime? I am using reporting service to generate letters. Some letters use a different font (can based on a field value), but I don;t really want to use a separate report for each one.

Changing a control attribute at runtime.


Hi Guys,

I'm basically trying to get a div containing a loading gif to show on my page at runtime. I call it from a button click event as well as in the code flow. It was working before I used the AJAX Update Panels. I've since taken them out as they were causing issues with RegisterClientScriptBlock. By the way, does commenting out the AJAX Markup like this...

<%--           <asp:UpdatePanel ID="up_search" runat="server">

...remove them from influence?
My div markup looks like this..
<div id="loading" style="visibility: hidden;" runat="server">
    <img id="loading_gif" alt="Loading..." class="loading" src="Images/panel_loading.gif" />

My code is initiated from the button click event.

    protected void btnSearch_Click(object sender, EventArgs e)

        //show the loading image

Getting WPF ListView Cell Content




I have a ListView that consists of single column horizontally oriented.

The cells contains textbox bount to a list.

How do I traverse the cells to access each textbox?

how to chnage page content type at runtime in MVC?



 I am working in asp.net MVC & on the view has to show both json & xml content depending on some condition.

I have to change the content type of the page  at runtime ie,

if the condition for json is fulfilled then set page contenttype = "text/json"


if the condition for xml is fulfilled then set page contenttype = "text/xml".


I have tried setting default content type on view as


@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" ContentType="text/json"%>

& in controller c

sharepoint changing content type layout has no effect on old pages




I have a content type layout. After I changed it, it had no effects on existing pages. 

When I add new page with this content type it has latest version.


How can I fix this? I want my current pages to use new content type layout.



DataGrid cell content with suffix - editing



I have a DataGrid in which i specify some converters in order to add suffixes to cells.

For example column of numbers that represent minutes i add " mins" to each cell.


Now when i edit the cell, i want the " mins" suffix to dissapear for the editing process and reappear when exiting edit mode. So that the user wont be able to change the "mins" suffix.


Cant figure a way to do it.

Please help.


DataGridCell Alignment Style Changing Width of Content?


It appears to when I use the following style to alter the cell alignment of a column, it is changing the width of the cell's contents to no longer expand to fill. This is problematic as it means I have to click in the narrow region shown in the second picture to edit the contents. What's the proper way to fix this?

Style code:


<Style x:Key="RightAlignStyle" TargetType="{x:Type DataGridCell}">
  <Setter Property="HorizontalAlignment" Value="Right" />


Width without Style:


Width with Style:

Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor
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