Problem with datagrid and TemplateColumns

G

Guest

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>
 
J

Joe Fallon

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::.. said:
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" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top