473,394 Members | 2,031 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,394 software developers and data experts.

Problem with datagrid and TemplateColumns

Hi can someone tell me how I get the values from a datagrid using template columns??? I tried like this but I keep getting

Input string was not in a correct format.

I don't think I'm doing this the correct why when it comes to using templatecolumns can someone please HELP!

Thanks!

...:: CODE
Dim pageID As Integer = CInt(e.Item.Cells(0).Text)
Dim modificationDate As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text

...:: INLINE CODE
<Columns>
<asp:TemplateColumn HeaderText="ID">
<ItemTemplate>
<%# Container.DataItem("pageID") %>
</ItemTemplate>
<EditItemTemplate>
<%# Container.DataItem("pageID") %>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Description">
<ItemTemplate>
<%# Container.DataItem("description") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="description" Columns="15" Text='<%# Container.DataItem("description") %>' Runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="add_Description" Columns="15" Runat="Server" />
</FooterTemplate>
</asp:TemplateColumn>
Nov 18 '05 #1
1 970
I use this technique:

Private Sub UnbindGrid()
For Each dgi As DataGridItem In dg.Items
If dgi.ItemType = ListItemType.Item Or dgi.ItemType =
ListItemType.AlternatingItem Then

'repeat/modify these two lines for each control
Dim otxtBox1 As TextBox = CType(dgi.FindControl("txtBox1"), TextBox)
myCollection.Item(dgi.ItemIndex).somefield = CInt(otxtBox1.Text)

Next
End Sub

--
Joe Fallon


"Tim::.." <myatix_at_hotmail.com> wrote in message
news:79**********************************@microsof t.com...
Hi can someone tell me how I get the values from a datagrid using template columns??? I tried like this but I keep getting
Input string was not in a correct format.

I don't think I'm doing this the correct why when it comes to using templatecolumns can someone please HELP!
Thanks!

..:: CODE
Dim pageID As Integer = CInt(e.Item.Cells(0).Text)
Dim modificationDate As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
..:: INLINE CODE
<Columns>
<asp:TemplateColumn HeaderText="ID">
<ItemTemplate>
<%# Container.DataItem("pageID") %>
</ItemTemplate>
<EditItemTemplate>
<%# Container.DataItem("pageID") %>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Description">
<ItemTemplate>
<%# Container.DataItem("description") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="description" Columns="15" Text='<%# Container.DataItem("description") %>' Runat="server" /> </EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="add_Description" Columns="15" Runat="Server" />
</FooterTemplate>
</asp:TemplateColumn>

Nov 18 '05 #2

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

Similar topics

0
by: sam | last post by:
Hello Group, The (web)datagrid I use has templateColumns. I have seen that I can make the boundColumn readonly when desired. And, the templateColumns does not have a similar property. Each...
3
by: rodrigo guerra | last post by:
i have a checkbox and a dropdownlist in 2 templatecolumns in a datagrid. how can i add a onClick/CheckedChanged event handler to a checkbox in the datagrid ? i want to enable a dropdownlist...
1
by: Mark | last post by:
I'm using TemplateColumns in a datagrid to allow a record to be edited. The record contains several columns that are dropdownlists that pull from "dictionary/ code-decode" tables. However, these...
2
by: Jade Seguin | last post by:
Hello, Hope somebody can help me with this cause I'm a ASP.NET beginner. I've created A DataGrid, and I added few BoundedColumns, and in my Page_Load section I added few TemplateColumns through...
0
by: Chris | last post by:
Ok, I think this is an easy one - I've just been staring at it too long. I'm creating a datagrid in asp.net/c# from scratch, i.e. nothing at all in the aspx page. I'm also creating all the...
4
by: Carlo Marchesoni | last post by:
I have an editable Datagrid and some columns (4 and 5) are TemplateColumns (because I have DropDownLists there). Everything works fine except that if I want to retrieve the values (that I can see...
1
by: John | last post by:
I have successfully built a datatable and datagrid for a user-selectable field interface. The user can select the fields they want, and the controlling table has the data type information. I can...
1
by: David Sagenaut | last post by:
Can I set a whole datagrid in edit mode, like a table? I can edit the data in the datagrid. After done, I can click the save button to save the data into a datasousce. I don't want to used the...
2
by: Steve Hershoff | last post by:
Hi everyone, I have a DataGrid with several TemplateColumns. One of these columns has an EditItemTemplate that contains an ASP.Net DropDownList. I'm catching this DropDownList's...
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:
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: 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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.