473,385 Members | 1,753 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.

Need help on template columns in datagrid

CW
In an earlier thread, I was asking for help on "Invalid attempt to
FieldCount when reader is closed" error when I was using a dataset rather
than a datareader to bind to a datagrid.

After playing around with it, I found out that the error was caused by
template columns. Once I remove template columns, everything worked fine.

Here are my scenarios and I would appreciate input on it.

My datagrid is bound to a orderlines table. In the edit mode, I want to
allow user to select product from a drop down list.

The steps I have followed are as follows:
(1) Turn the product model column into a template column.
(2) Edit this template column to include an unbound drop down box (called
DDLModelNumber) in the edit template mode. Originally I also had a drop down
box in the item template mode. However, this would cause the invalid field
count error when the form first loads.
(3) In the ItemCreated event, I would use
e.item.findcontrol("DDLModelNumber") to determine whether I am in edit mode.
If I am, then I would populate the drop down list, and then set its
SelectedIndex to the current selection.
(4) On update event, I would write the change back to the server by grabbing
the value from DDLModelNumber.

However, I found that I get this dreaded Invalid Field Count error after I
click edit on the datagrid (which would firstly populate the grid, as well
as the DDLModelNumber drop down box, and then attempt to DataBind). For some
reason, when calling databind method, if I have a drop down list in the
template, it causes this invalid field count error.

I would appreciate input on (1) how to get around this drop down list
conflict with databind operations and (2) whether the method I am using is
the best way to achieve the functionalities I am after.

Thanks in advance
Nov 18 '05 #1
2 1510
Hi,

What's the AutoGenerateColumns value of your datagrid
Can you show your code

Bin Song, MCP
Nov 18 '05 #2
CW
AutoGenerateColumns is false.

I found a few articles from MSDN website, and now have got it working.

Thanks for the help.
"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
Hi,

What's the AutoGenerateColumns value of your datagrid?
Can you show your code?

Bin Song, MCP

Nov 18 '05 #3

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

Similar topics

0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event...
4
by: | last post by:
I have a datagrid with a template column that has a hyperlink and a label. The hyperlink text is bound to Title from my dataset and the label text is bound to Author in the dataset. The grid...
2
by: Nicole | last post by:
I am creating template columns programmatically. I have read the msdn article on this and I'm so close. Article:...
2
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After...
1
by: William Gower | last post by:
I need to develop a datagrid that uses columns from a table. In addition I need two columns (checkboxes) that the user will use to indicate that this record can be closed later. The checkboxed...
4
by: starwiz | last post by:
I'm trying to use the DataGrid's editing with a DropDownList. I've tried using every code sample I've seen and none of them seem to be able to solve my problem. When I call...
2
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
1
by: Brett Wesoloski | last post by:
I am new to using template columns. I am just trying to create a data grid with a bound column and another column with a imagebutton in it. What I have always done in the past was to then create...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.