.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

Silverlight - Dynamically generating a table for datagrid

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery

Hi there,


I am parsing a table in my Silverlight application. Lets say the table is as follows

*   A   B   C

A   1   2   3

B   3   4   6

C   2   2  2

I do not know before hand the column names, how many columns there are so, as far as I know, I can only see a solution to presenting this as a table with the traditional unbound data strategy as in windows forms.  However, my solution is in Silverlight, so I necessarely need to bind to an object.  But as said, I do not know the object properties, so I got stuck.  Please help; this seems like it should be very simple to display a parsed table.


Many thanks. 


View Complete Post

More Related Resource Links

Building a 3-Tier App with Silverlight 3, .NET RIA Services, and Azure Table Storage

Silverlight 3, .NET RIA Services, and Windows Azure Services Platform makes a 3-tier Cloud application easier to build: Silverlight 3 as presentation tier, .NET RIA services as the business logic and data access tier, and Windows Azure Table as the data storage tier. The sample application in this article demonstrates the architecture with a simple Survey application with all these technologies working together from Windows Azure.

DataGrid: Tailor Your DataGrid Apps Using Table Style and Custom Column Style Objects


One of the most enduring challenges in writing user interfaces is figuring out how to display large amounts of data efficiently and intuitively without bewildering the user. The problem becomes particularly thorny when the interface must reflect hierarchical relationships within the data that the user needs to modify. The Windows Forms DataGrid control gives developers a powerful and flexible tool to meet this challenge. This article explains its basic operations and shows how to extend the DataGrid to display columns of data in an application-appropriate manner.

Kristy Saunders

MSDN Magazine August 2003

Cutting Edge: Creating a Multi-table DataGrid in ASP.NET


If you bind a multi-table DataSet to a DataGrid, only the first table is recognized. Here Dino Esposito writes a custom solution the the multi-table problem.

Dino Esposito

MSDN Magazine August 2003

Change Templates Dynamically in Silverlight


Silverlight has the flexibility to modify the look of your controls dynamically at runtime with just a few lines of code. Take a look at Figures 1 and 2 and you will see two different views of the same list box and data. To accomplish this, you simply need to setup two different resources of XAML code that you can switch between at runtime.

More Detail 
Figure 1: More detail

Less Detail 
Figure 2: Less detail

The Product Class

For this example, I will be using a simple Product class with four properties, and a list of Product objects using the Generic List class. Create a Product class as shown in the following code:

public class Product {
  #region Constructors

  public Product(){ }

  public Product(int id, string name, string type, decimal price)
    this.ProductId = id;
    this.ProductName = name;

Want to Create Table Dynamically With text Control in WinForm Csharp

Hello To All... from Many Days i m tryng to create a simple table using csharp in WinForm.Which will include textbox in each cell according the Passed No of Col & Row. but not getting the proper result. Actually i want to trace each cell data and want to save each cell data to data base : eg. in cell 11(1col & 1row) i m having Combobox which having some item list and when the user select the list item the data will save to the database. Regards, Praveen    What is the Key of Life ... Its Sharing Your Thought & Knowledge ...

dynamically add scrollbars to datagrid

 I am creating multiple datagrids at runtime within a placeholder. I want to add scrollbars to them.Please can someone help me as i dont know how to add scrollbars to datagrids created at runtime.I am using .net 1.1

Refresh Silverlight datagrid

In a Silverlight page I have a datagrid (items loaded from a SP list) and below it a dataform that lets the user make edits to the items displayed in the datagrid when a row is selected from the datagrid.  However, when a user makes an edit to an item using the dataform, the datagrid doesn’t get refreshed when I re-query (via CAML) the SP list to refresh the datagrid.  Only if I change another item in the dataform, does the datagrid then refresh as expected. Code when I Edit the list item in the dataform: public void EndEdit() { ClientContext context = new ClientContext(ApplicationContext.Current.Url); context.Load(context.Web); _skills = context.Web.Lists.GetByTitle("Skills_NewRequest").GetItemById(skillId); _skills["TimeStamp"] = TimeStamp; _skills["Parent"] = Parent; _skills.Update(); context.ExecuteQueryAsync(OnRequestSucceeded, OnFailListener); } private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args) { Deployment.Current.Dispatcher.BeginInvoke(BindData); } private void BindData() { //MessageBox.Show("Your request has been submitted!"); }   And here’s the code for refreshing the datagrid: private void dataFormNewPending_EditEnding(object sender, DataFormEditEn

delete more than one row in datagrid in silverlight 3

I tried to delete more than one row in datagird in silverlight, using chechbox checked, and binding to itemsource. I have following code: ---------------------- Orderlist = (System.Collections.ObjectModel.ObservableCollection<SilverlightWebService.Order>)dgOrders.ItemsSource;  System.Collections.ObjectModel.ObservableCollection<SilverlightWebService.Order> orderlist1 = new System.Collections.ObjectModel.ObservableCollection<ConcourseSilverlight.SilverlightWebService.Order>(); foreach (SilverlightWebService.Order aorder in Orderlist) { if (aorder.CheckedItem == false) orderlist1.Add(aorder); }  dgOrders.ItemsSource = orderlist1; -------------- DataGrid will be repopulated. But values selected will be defaut ones, that means data selected is not retained. may be itemsource is changes. how can I resolve this        

Dynamically constructing a table of results using Ajax and MVC

I need to implement a search page where a user will be able to specify some search criteria and perform a search. It's a requirement that the results are displayed on the same page, beneath the search criteria.I have a simple prototype that works, but I'd appreciate it if someone can sanity check my idea in case there's a much better or simpler way to do it.Here's the code for the controller class:namespace MvcAjaxTableCreation.Controllers { public class HomeController : Controller { public ActionResult Index() { return View(); } public string GetTableData() { return "<table border=\"1\"><tr><td>Product Category</td><td>Product Name</td></tr><tr><td>Category1</td><td>Product Type A</td></tr><tr><td>Category1</td><td>Product Type B</td></tr><tr><td>Category1</td><td>Product Type C</td></tr></table>"; } } } For simplicity, the table string above is hard coded but would be constructed dynamically in the real code.I also have the following form defined In the body of my html: <% using(Html.BeginForm("GetTableData", "Home")) { %> <input type="submit" value="

How to dynamically add table rows within update panel ?

Hi, In my webform, i have 3-4 textbox, on there textchange event i have to fetch data from database and put it on the form. I have taken another html table (with runat="server")  below textbox and  and in textchange event created a new <tr>, <td> and simply added contents in <td>, then finally added <tr> in the table. This is done in UpdatePanel. When i enter something in textbox1 data is added in that table,that's fine. But when i enter something in 2nd textbox the previous data is overridden. My requirement is that if 2nd textbox's text changes than another row with appropiate data should be added, i.e., now two rows. Silimarly if 3rd ,4th textbox data changes then subsequently 3 or 4 rows should be displayed. What should i do ?

Dynamically fill query parameters in a table adapter ?

SO I have created an object data source on a page from a table adapter using the various Wizards in Visual Studio.Its meant to query a diary Database by a DateTime parameter called diaryDate. I want to query from a date Now to the next 14 days ahead.I want to display the entries in a Grid View when the page loads.So I'm a bit stuck now as to how to set the two query parameters date1 and date2. I want to set date1 = now() and date2 = now() + 14 days.How do I set those parameters when the page loads ?Should I have used the adapter Wizard approach of do I have to write all the code in the code behind page ??This is my datasource code'<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GET_nextTwoWeeks" TypeName="query_getNextTwoWeeksTableAdapters.diaryDatesTableAdapter"> <SelectParameters> <asp:FormParameter DefaultValue="" FormField="date1" Name="date1" Type="DateTime" /> <asp:FormParameter DefaultValue="" FormField="date2" Name="date2" Type="DateTime" /> </SelectParameters> <InsertParameters>

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.

Dynamically generating of hot spots on image


HI all,
           I am facing problem with the dynalically generating the image at particular with coordinate points on image map through code behind (aspx.cs).
    As per my requirement i need to generate Hotspots dynamically and also displaying an image to indicate the Hot spots.
Please send me the code above that ...

thanks in advance

Create table dynamically in SQL Server


hi all,

i want to create temparory table dynamically in sql server,

well, it depends on the fields that are passed from front end as comma seprated value..

and that table shoud contain only that fields that are passed  from front end,

help me on this if it is possible,


Thanx in advance,

Sagar Joshi

InfoPath Forms : Adding rows dynamically from a SQL table along with a 'Delete' button per row


My requirement is something like this:

In a Task Approval form, I want to have a view which shows all the rows in a particular SQL table (in a infopath repeating table?). Along with each row, there should also be a button, on clicking which the row should disappear from the infopath view table. Do you think InfoPath can handle all this? :) 

To summarize:

1. How do I add rows to a table dynamically?

2. Per row, how do I create a button dynamically?

3. How do I remove the row from the view when the button is clicked?

Unable to create table dynamically in database


I am able to create database through script generated by SQL Server 2008 but unable to create tables from generated script. Please indicate if any step is missing.


************* Code *******************

 public bool CreateAppTables(string DatabaseName, string ConnectionString)
        string DatabaseScript;
        DatabaseScript = Activity.readTextFile(HttpContext.Current.Server.MapPath(".") + "/functionalscripts/CreateTablesonly.sql");
        DatabaseScript = DatabaseScript.Replace("DatabaseNametoChange", DatabaseName);
        return ActionQueryDB(DatabaseScript, ConnectionString);


 public bool ActionQueryDB(string SQLStatement, string ConnectionString)
        //  SqlConnection cn;

        OleDbConnection cn = new OleDbConnection();

        cn.ConnectionString = ConnectionString;
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandText = SQLStatement;
            cmd.Connection = cn;

            return true;
        catch (Exception ex)

            return false;


****************** Contents of text file appe

How to create a Table of content in .rdl design in BIDS dynamically according to the Page no wise..?



well i am able to create the TOC statically by using the Document Map properties as describe in my older post issue 

but now i just want to create the Table of contents dynamically generate using the page no wise..is it possible...how can we do it while designing the .rdl in BIDS..



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