473,408 Members | 1,601 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,408 software developers and data experts.

Building a datagrid in code

I'm developing an asp.net ascx control that will allow editing of any
database table. After getting table names and columns from
INFORMATION_SCHEMA I have to build a datagrid in code consisting of template
columns with a textbox in each ItemTemplate.

For each column I build the following code works fine....

dim myCol as new TemplateColumn
myCol.headertext = row("COLUMN_NAME")
dim myTB as new Textbox
myTB.ID = row("COLUMN_NAME")

So, now I have a TemplateColumn and a textbox but I can't figure out how to
put the textbox into the template column before I do dg.columns.add(myCol)

I've tried various assignments and casts with no success thus far.

Anyone know how to do this? Anyone know of a knowledge base that addresses
building grids in code and assigning the various attribute values - all the
same things we do with property builder.

Thanks,
T
Nov 19 '05 #1
4 1344
Hi Tina,
You can find a sample which shows binding a textbox at runtime and adding it
to the datagrid at this url
http://www.expertszone.com/samples/textboxtemplate.zip
hope you find it useful.. In case u need more information please get back to
me..
--
The best
srini
http://www.expertszone.com
"Tina" wrote:
I'm developing an asp.net ascx control that will allow editing of any
database table. After getting table names and columns from
INFORMATION_SCHEMA I have to build a datagrid in code consisting of template
columns with a textbox in each ItemTemplate.

For each column I build the following code works fine....

dim myCol as new TemplateColumn
myCol.headertext = row("COLUMN_NAME")
dim myTB as new Textbox
myTB.ID = row("COLUMN_NAME")

So, now I have a TemplateColumn and a textbox but I can't figure out how to
put the textbox into the template column before I do dg.columns.add(myCol)

I've tried various assignments and casts with no success thus far.

Anyone know how to do this? Anyone know of a knowledge base that addresses
building grids in code and assigning the various attribute values - all the
same things we do with property builder.

Thanks,
T

Nov 19 '05 #2
srini,
This is what I am looking for! However I'm having a little trouble cooping
with your C# as I am a vb developer. What does:
txtTemp.databinding += new System.EventHandler(BindTextBox)
do?

I think it is raising an event but my C# to vb translator can't handle it.
Thanks,
T
"srini" <sr***@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
Hi Tina,
You can find a sample which shows binding a textbox at runtime and adding
it
to the datagrid at this url
http://www.expertszone.com/samples/textboxtemplate.zip
hope you find it useful.. In case u need more information please get back
to
me..
--
The best
srini
http://www.expertszone.com
"Tina" wrote:
I'm developing an asp.net ascx control that will allow editing of any
database table. After getting table names and columns from
INFORMATION_SCHEMA I have to build a datagrid in code consisting of
template
columns with a textbox in each ItemTemplate.

For each column I build the following code works fine....

dim myCol as new TemplateColumn
myCol.headertext = row("COLUMN_NAME")
dim myTB as new Textbox
myTB.ID = row("COLUMN_NAME")

So, now I have a TemplateColumn and a textbox but I can't figure out how
to
put the textbox into the template column before I do
dg.columns.add(myCol)

I've tried various assignments and casts with no success thus far.

Anyone know how to do this? Anyone know of a knowledge base that
addresses
building grids in code and assigning the various attribute values - all
the
same things we do with property builder.

Thanks,
T

Nov 19 '05 #3
all kinds of datagrid help here

http://www.datagridgirl.com/

-----------------------------------------------------------------
Faith is so easy, no thought required
Nov 19 '05 #4
hi Tina,
This line translates to
AddHandler txtTemp.databinding , AddressOf BindTextBox in vb.net. I am
adding a event handler to the txtTemp textbox here.
--
HTH
srini
http://www.expertszone.com
"Tina" wrote:
srini,
This is what I am looking for! However I'm having a little trouble cooping
with your C# as I am a vb developer. What does:
txtTemp.databinding += new System.EventHandler(BindTextBox)
do?

I think it is raising an event but my C# to vb translator can't handle it.
Thanks,
T
"srini" <sr***@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
Hi Tina,
You can find a sample which shows binding a textbox at runtime and adding
it
to the datagrid at this url
http://www.expertszone.com/samples/textboxtemplate.zip
hope you find it useful.. In case u need more information please get back
to
me..
--
The best
srini
http://www.expertszone.com
"Tina" wrote:
I'm developing an asp.net ascx control that will allow editing of any
database table. After getting table names and columns from
INFORMATION_SCHEMA I have to build a datagrid in code consisting of
template
columns with a textbox in each ItemTemplate.

For each column I build the following code works fine....

dim myCol as new TemplateColumn
myCol.headertext = row("COLUMN_NAME")
dim myTB as new Textbox
myTB.ID = row("COLUMN_NAME")

So, now I have a TemplateColumn and a textbox but I can't figure out how
to
put the textbox into the template column before I do
dg.columns.add(myCol)

I've tried various assignments and casts with no success thus far.

Anyone know how to do this? Anyone know of a knowledge base that
addresses
building grids in code and assigning the various attribute values - all
the
same things we do with property builder.

Thanks,
T


Nov 19 '05 #5

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
0
by: admin | last post by:
New Article Building a DataGrid with Add and Edit Features By Tulga Kalayci The DataGrid server control is one of the most widely used controls in ASP.NET-based projects to display data in a...
3
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control,...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
by: Brian Shannon | last post by:
I have 3 combo boxes and two date text boxes on a .aspx page. The user can fill in any of the 5 controls or none to filter a datagrid. I was hoping someone could explain how to efficiently build...
0
by: Craig G | last post by:
i want to build a datagrid to use as a register for a number of courses. what i want to happen is that the tutor selects the course from a combo box. this then builds a grid for all students...
1
by: Tom | last post by:
Forgive the newbie question but any help would be appreciated. I built a simple form and want to place a datagrid on it that would be based on two tables. I created the sqlconnetion and two...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.