Dynamically create controls in GridView template column

Hi,

this is my first post so please be nice :)

I have a situation where I'm loading GridView from XML data source and I need to dynamically create a TABLE control inside grids template column.

One of table's columns has an editable TextBox, so there could be unknown number of rows in a gridview and unknown number of rows in each table.

At the moment I'm creating those tables inside  GridView_RowDataBound event and all works fine.

Problem is that when user clicks in "Update" button table controls are gone because they are dynamically created.

My question is how can I create those dynamic tables outside RowDataBound event and somehow inject them into the grid? GridView.DataBound() is called only when its not a PostBack, but I need to recreate tables on each page load.

 
Any ideas? Thanks. 

 

 

0
esharp
5/5/2008 7:06:28 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
552 Views

Similar Articles

[PageSpeed] 3

never mind, solved the problem using gridview inside a gridview. 

0
esharp
5/6/2008 11:43:32 PM
Reply:

Similar Artilces:

User Control controls not created when dynamically creating user control
  Have created a user control for displaying and editing a dynamically number of values. The user control contains two labels and an edit box. When dynamically loading the user control I get an error when the control itself tries to change setting on the fields within the user control.   Why doesnt this work? It works okay if I dont load it dynamically but create a user-control-instance in the aspx-page but thats no solution.   Thankyou!     Here is my code:   ucDataValue.ascx   <%@ Control Language="C#" AutoEventWireup="true&...

Gridview and dynamically created controls
Hello, I have a gridview with a lot of rows. This means I can't create the the correct controls (like dropdowns) at once but I have to create them once the user wants to edit a row. Anyhow, this is an example of how I create a dropdown:  Dim lstPersCat As New DropDownList lstPersCat.ID = "lstPersCat" Dim strUserGroups(10) As String strUserGroups = retUserGroups(CType(gvResults.Rows(e.NewEditIndex).Cells(9).Controls(0), TextBox).Text.ToString) For i As Integer = 0 To strUserGroups.Length - 1 If Len(strUserGroups(...

remove a gridview column dynamically, removes controls in template columns
I have a interface with a treeview and a gridview. The gridview has two templatefields that handles insert/update/deletes. The gridview is handling editing of different tables so I create the other columns in the gridview dynamically as boundfields. The user selects the table to edit in the treeview. The problem I am having happens when the user selects a table to edit the second time. The code that executes removes all bound fields, (dynamically added when user selected the first table in the treeview), but not the two template fields, and then adds boundfields specifi...

Create Dynamic Dropdownlist Controls / How to Create Dynamic Dropdownlist Controls
Hi,    This might be useful for someone who strucks with create dynamic dropdownlist/ controls. In ASP.Net is page is stateless. when you are creating the dynamic dropdownlist control following issues you might be facing, 1. After loaded the control, on selected index changed event the control will be disappear. 2. The selectedIndexChanged raised event might not be fired when selection of Dropdownlist. 3. Locate the exact dropdownlist which you created dynamically. 4.Placing this dynamic controls in exact location in the page. Solution: You have to re-create the con...

create and add controls dynamically to dynamically created Table Control
How can i create web server Table control dynamically with vary number of  rows and columns, and  then adding  further  other controls(like  dropdown, Text box etc.)  randomly to the specific created Table Cells. First of all you should use PlaceHolder control to add Table control to it:<asp:PlaceHolder id="PH" runat="server"></asp:PlaceHolder>Code Behinde:Table t = new Table();TableRow tr = new TableRow();TableCell td = new TableCell();//td.Text = "Hello, I am a TD";// Here well create TextBox and add it to TDTextBox txt = new TextBox();tx...

dynamically create controls inside the template section of a control
 Hello,I need to dynamically create controls inside the <LayoutTemplate> section of the <asp:Login > control.  How can I achieve this?<asp:Login ID="Login1" runat="server"etc<LayoutTemplate><asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">etcetc/* PROGRAMMATICALLY ADD A CONTROL HERE */</LayoutTemplate></asp:Login>  Any help will be appreciated. Thanks.Mc  hello, nobody please? Not sure how you can do it but try this: Place a container control&n...

Creating Dynamic Controls in Gridview Columns
I need a gridview that needs to show information about a product and show information about this product. In the gridview I also want to run a count of how many products there are. To do this I have used an sqldatasource to bind the select information that is about the product and then in the Gridview Databound event i use another sqldatasource to query the Count for each product and then attach to the last column. This all works fine and gets me the results. idont know if it is effecient but it works. I now want the count column to be c...

postback from dynamic controls to create more dynamic controls
Hi, Could any one help me?  I have a masterpage with dynamically created list boxes.  When the user selects an item from the listbox the selected value will be used to dynamically create a set of controls in the contentplaceholder.  The problem i have is that the item selected from the list box is posted back and i do not know what the selected item is until the life cycle is complete.  During the post back is there a way to findout which listbox control performed a post back and its value before i get to the init part of the content page where i woul...

Bubbling Events on Dynamically created controls that are on dynamically created user-controls on a module!! HELP MAH PUHLEASE!
I may be cross posting this question, but I am really going to go crazy.. Please help if you can!I think I am going to go mad. If anyone can help me with this small issue, I will build an idol in your image made of clay, and have nubile maidens dance in front of it in worship!!!!I have a module. Let's call it Module-1Module-1 Connects to a database and gets a list of items.Module-1 Then creates on the fly a number of buttons that represent that list of items.Each button when clicked dynamically creates a web-user control. Let's pull out 1 button, and 1 usercontrol and call them Button-1 and ...

Loading controls dynamically based of previously dynamically created control
Hi All, Heres the deal. I have a hierarchal or tree structure of data that needs to be represented in dropdownlists (ddl). The root is a single ddl and the items in the ddl are children of the root. When a child is selected I need to add another ddl to the control collection with it's children as listitems. Its like dropdownlist chaining without knowing the order of the dropdownlists. Now I know I can use the Page.OnInit method to add the ddl, but since viewstate is not loaded until after OnInit is called I don't have access to the selected child. Right know I am getting around this by u...

Dynamically creating controls in a Table control
Hi I'm using a Table control to create a table in a Webform, however I need to be able to create additional controls within certain cells for instance an ImageButton where I can then build an event handler for each one I dynamically create. How do I do this, I've been trying add the control to the Controls collection of either the Page or the Table - all with poor results. Normally I'd add a control into a place holder, but again that's something that I'd need to dynamically create also in each cell I suppose...? Please help! Thanks in advance. get the HtmlTableCell e.g. H...

trouble creating a reusable GridView with dynamic Template command Columns VB.NET
I've created a single GridView control that I want to reuse.  My goal is to bind the initial dataset with a programmatically created command column, pass the arguments to a universal RowCommand event handler and dynamically change the DataSource, commandArgument, commandName, and Databind again. I haven't had any success in implementing this idea.  I've tried creating separate template class and Import it, but then I'm unable to assign the properties to the Command column. I just need someone to point me in the right direction.  I've found hundred...

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

Dynamically created controls and viewstate in a composite control
Hello there, I've been trying to build a custom composite control and i'm having a hard time figuring out what's going wrong in this example. First the code behind of the test page... using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace ViewStateTest { /// <summary> /// Summary description for WebForm...

Web resources about - Dynamically create controls in GridView template column - asp.net.presentation-controls

Placebase team at Apple file “Schematic Maps” patent dynamically detailing important data
In a report from Computerworld way back in 2009, we learned that Apple had quietly acquired Maps API company Placebase. Then, founder of Placebase ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

In a dynamically typed language, is it a bad idea to return different data types?
In some cases, returning different types from a single function works.

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 1/16/2016 3:02:30 PM