473,385 Members | 1,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Itemplate viewstate

Hello,
I am trying to create textbox control dynamically into a datagrid.
I do not know the number of columns until run time so I thought I could use
template columns dynamically and add them into the datagrid.
This works fine, but on post back all the data in the datagrid disappears.
Any idea why? I have the bad feeling that the view state has something to
do with it.
I do have viewstate enabled.
Note: I am implementing the Itemplate interface and I have Implemented the
InstantiateIn mehod.
Thanks!

Nov 19 '05 #1
1 2328
Controls which are created dynamically must be recreated dynamically on
postback in order to exist.

One solution is to use the OnItemCreated even to create the controls:
http://openmymind.net/databinding/index.html#4.3

Another might be to use Denis Bauer's free dynamic control placeholder,
which might do the trick:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Amine" <Am***@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hello,
I am trying to create textbox control dynamically into a datagrid.
I do not know the number of columns until run time so I thought I could use template columns dynamically and add them into the datagrid.
This works fine, but on post back all the data in the datagrid disappears.
Any idea why? I have the bad feeling that the view state has something to
do with it.
I do have viewstate enabled.
Note: I am implementing the Itemplate interface and I have Implemented the
InstantiateIn mehod.
Thanks!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cosine... zero | last post by:
Hi! I've got a databound templated control that I want the itemplate class itself to be postback aware to process form data. But calling Page.RegisterRequiresPostBack( instantiatedtemplate )...
0
by: Steve Richter | last post by:
trying to understand how to support templates in server controls ... a few quick questions on the following snippet of code pulled from a server control class: ITemplate _headingStyle; ...
0
by: vicgroups | last post by:
Hello, I am adding columns to the datagrid programmatically. And I have created a countries drop down list in an ascx file. I have added the countries drop down list to the datagrid column as...
0
by: Amine | last post by:
Hello, I am trying to create textbox control dynamically into a datagrid. I do not know the number of columns until run time so I thought I could use template columns dynamically and add them into...
0
by: LaptopHeaven | last post by:
I am having some trouble. How would one load a custom UserControl fro within a class which impements the ITemplate interface. Currently I have the following: public class...
5
by: Ben Schumacher | last post by:
Ok smart guys and gals ... I have a GridView control with a dynamically created checkbox column. The checkbox is created using ITemplate interface. In my class that implements the ITemplate...
0
by: imranabdulaziz | last post by:
Hi all, I am using asp.net2.0 and C# VS2005. I am creating asp.net web server control templates Dynamically . My requirement is such that sp return very no of field( 4 or 5 or 6 …). Now I am...
0
by: John | last post by:
I'm dynamically creating all the Columns in a GridView at run time and binding it to a DataTable. I have to build it at runtime (using an ITemplate subclass) because the number of columns is based...
1
by: wojski696969 | last post by:
Hi, i've made my own Custom Server Control, wich inherits from WebControl class. Inside of my control I've create three ITemplate properties wich should be used as containers for Head, Content and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.