.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

Dynamically changing the Style of TreeViewItem

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


I am currently setting the style to the Treeview control inside Treeview.Resources which works fine. I need to change the Style dynamically when user changes selection in another control. Any thoughts on how this can be done?

Here is my current working code.

<TreeView Name="NavigationPaneTreeView" SelectedItemChanged="NavigationPaneTreeViewSelectedItemChangedEventHandler"



View Complete Post

More Related Resource Links

Dynamically Changing ImageUrl in HyperLink control


Hey guys,

C#/.net newb alert. ;)

I'm writing a script and need help with being able to modify the ImageUrl property in a HyperLink control from the code behind page. It is meant to dynamically show an image.

I just need to know the correct format of the code behind to get this to work.


Changing data item value Repeater dynamically


How do i dynamically change the value of dataitem in repeater control(.net 2.0,VS 2005)..i have repeater something like this :
<asp:Repeater ID="rptGameInfo" runat=server OnItemDataBound="itemDataBound_rptGameInfo"  >
<HeaderTemplate >

<ItemTemplate >
<asp:Label ID="lblLoc" runat=server Text="Location:" ></asp:Label><%# Eval("GAME_LOCATION")%><br />
</ItemTemplate >

and it shows the result like this:

If location is "Select" i want to change it to "n/a". So i am trying to capture it in itemDataBound even something like this

if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
                DataRowView row = e.Item.DataItem as DataRowView;
                string location = row["GAME_LOCATION"].ToString();

                if (location == "Select"

Dynamically changing SqlDataSource.SelectCommand from FormView.ModeChanged


In an asp.net 3.5 web app, I have a page with the following markup/code (this is the brief version, but I believe I got all the relevant info).

<%@ Page Language="VB" AutoEventWireup="false"   %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<script runat="server">

    Private Shared FormMode As String
    Private Shared ParentSrID As Integer
    Private Shared SRRow As DataRowView
    Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim button As String = GetPostBackControl(Me).ID
        Select Case button
            Case "EditButton"
                FormMode = "Edit"
            Case "UpdateButton"
                If Not frmSR.CurrentMode = FormViewMode.Edit Then
                    Catch ex As HttpException
                    End Try
                End If
            Case "CancelButton" 'Cancel SR Add/Edit
        End Select
    End Sub
    Protected Sub frmSR_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles frmSR.DataBound
        'We want to use the current record

dynamically changing points in a PathGeometry


I have a PathGeometry that is initially set with points captured from inkCanvas Strokes, I want to iterate through them & translate the points to properly display on a geodetic map - how would I modify the points dynamically so it would be translated to the map control?


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:

Dynamically bind to often changing database



Please point me to the right forum if this is not correct - I do appreciate it :-)

At work we have a database that needs a table maintenance utility written in c#/aspx/webforms. The database has about 45 tables and that could change fairly frequently.

The utility needs to present the user with a drop down of all the tables in the database, (ok - easy so far. I can get this dynamically from the database to allow for addition/deletion of tables). The user chooses a table name and is presented with the data in the table. The user can edit the data, delete or insert rows, page through the data, etc. I am guessing this is a gridview.

I can get the columns for the selected table name dynamically from the database too, but I do not seem to be able to write a generic page that uses code to bind the gridview to the data and lets the user page, insert or delete rows, etc.

In the designer a sql datasource on non-changing tables this would be easy. (Point the sds at the table, write a couple of stored procedures to add/delete/select rows, etc and the job is done).

What I don't seem to be able to do is write a generic page that will cope with dynamic binding of the grid to the database. i want to write a page that is fairly 'decoupled' from changes in the database but will still be able to provide a useful table-maintenance type tool.

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.NET repeater control - databind with style

even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nice looking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files.

A Simple and Extensible Radio Button Style GridView

The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

Dynamically Create Controls in ASP.NET by Using Visual C# .NET

This article demonstrates how to dynamically create a control for an .aspx page. The sample project does the following:
Creates two TextBox controls.
Verifies that the contents (TextBox.text) and the attributes of the TextBox are saved across posts to the server.
Illustrates handling events that are posted by a dynamically-created control

Dynamically Create Controls in ASP.NET with Visual Basic .NET

This step-by-step article describes how to dynamically create controls for an ASPX Web page.

The sample project does the following:
It creates two TextBox controls.
It verifies that the TextBox contents (TextBox.text) and attributes are saved across posts to the server.
It describes how events that are posted by a dynamically created control are handled.

Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


Gmail style multiple Sign-in type combo...is it possible in asp.net?


I am developing a multi-company application and want my users to give the functionality like the following to switch companies.


Is this possible? then how?

Please help


MS Word style comments in asp.net



I need to create a system, that will be similar to ms word style comments. So the idea is the following: on the page there are a pack of text boxes labels and so on, and user need have the way to comment each control, and save commented text, for example to DB, so the others can reed comments too.

I tried PopUpControlExtender, but it works in single way, and i cannot view all the popups in one time. Or may be i missed something and there is a way to popup all the controls at one time? 

Therefore, are there any known solutions for a discribed task, based on PopUpControlExtender or something else?

using the linqDataSource control programmatically (dynamically)



my scenario is this: I want to use the linqDataSource control to bind data to a gridview for it's efficient built-in paging and sorting features *but* I don't want the data to be bound until the user has input various search parameters, so I need to bind the data from a button click event. Also, the search options will be somewhat complex in that there will be several optional search parameters, via various dropdowns and textboxes, so I can't just declaratively/statically setup all the WHERE parameters on the linqDataSource (at least I'm assuming I can't, or that it may result in poor performance if I do and just assign default values like the everything wildcard '%' for the cases the user doesn't use a particular search parameter). Given that brief description, here is an example of what I'm doing, but with only one WHERE parameter for simplicity, the real code will be adding anywhere from 1 to about 12 WHERE parameters depending on how the user sets the search options in the GUI.

the linqDataSource on the aspx page:

<asp:LinqDataSource ID="ldsMain" runat="server" 
        Select="new (field1, field2, field3, etc..)" 

Search for a string in my datasource dynamically


I am displaying an Rssfeed on my page by using XmlDataSource and Datalist controls.

I want the user to be able to limit the information that is returned to my datalist.  To do this I have a textbox on the form that allows the user to enter their search criteria.

I need to be able to dynamically create a query string utilizing the information that the user entered in the textbox.  I am also using a drop down list and allowing the user to select whether they want to search in the title, description, or all parts of the xml file.

I am having trouble figuring out how to reference the data contained in my textbox in my query string.  Where the query string says 'asp', I want to replace 'asp' with the content from my sSearch variable.  Can anyone tell me how to reference my variable in the query string???

string sSearch = txtSearch.Text;
        string SQuery = "";

        if (DropDownList2.SelectedIndex == 0)
            SQuery = "[contains(title), 'asp')]";

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