473,467 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Referincing datagrid with hidden and template column

OK. Now I got around to getting values out of the datagrid in the
OnUpdateCommand rutine:

Datagrid:

<asp:BoundColumn Visible="False" DataField="EmployeeID"
HeaderText="EmployeeID" />

<asp: TemplateColumn
SortExpression="Employee"
HeaderText="Employee">
<ItemTemplate>
<asp:Label
ID="lblEmployee"
runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.Employee") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
runat="server"
id="txtEmployee"
Text='<%# DataBinder.Eval(Container, "DataItem.Employee") %>' />
</EditItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn
SortExpression="EmployeeGroup"
HeaderText="EmployeeGroup">
<ItemTemplate>
<asp:Label runat="server"
Text='<%# DataBinder.Eval(Container, _
"DataItem.EmployeeGroup") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList Runat="server" ID="cboEmployeeGroup"
DataSource="<%# GetEmployeeGroup() %>"
DataTextField="EmployeeGroup"
DataValueField="EmployeeGroup" />
</EditItemTemplate>
</asp:TemplateColumn>

I get the values using:

Dim iEmployeeID As String = _
CType(e.Item.Cells(0).Controls(0), TextBox).Text

Dim sEmployee As String = _
CType(e.Item.FindControl("txtEmployee"), TextBox).Text

Dim sEmployeeGroup As String = _
CType(e.Item.FindControl("cboEmployeeGroup"), _
DropDownList).SelectedValue

New problem: I get the original values from the TextBox or
DropDownList controls and not the new values entered in the TextBox or
selected in the DropDownList (displayed inthe EditItemTemplate part in
edit mode...!!!)

I'm really confused.
It still seems to be the referencing of the template column that I
can't get right.

I've tried:
For Each dgi As DataGridItem In dg.Items
If dgi.ItemType = ListItemType.EditItem Then
....
but it doesn't work

/Morten

Nov 18 '05 #1
1 2311
Found the answer here:
http://datawebcontrols.com/faqs/Prog...ts.print.shtml

On Sat, 18 Sep 2004 15:09:54 +0200, hansiman <ha***@hotmail.com>
wrote:
OK. Now I got around to getting values out of the datagrid in the
OnUpdateCommand rutine:

Datagrid:

<asp:BoundColumn Visible="False" DataField="EmployeeID"
HeaderText="EmployeeID" />

<asp: TemplateColumn
SortExpression="Employee"
HeaderText="Employee">
<ItemTemplate>
<asp:Label
ID="lblEmployee"
runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.Employee") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
runat="server"
id="txtEmployee"
Text='<%# DataBinder.Eval(Container, "DataItem.Employee") %>' />
</EditItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn
SortExpression="EmployeeGroup"
HeaderText="EmployeeGroup">
<ItemTemplate>
<asp:Label runat="server"
Text='<%# DataBinder.Eval(Container, _
"DataItem.EmployeeGroup") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList Runat="server" ID="cboEmployeeGroup"
DataSource="<%# GetEmployeeGroup() %>"
DataTextField="EmployeeGroup"
DataValueField="EmployeeGroup" />
</EditItemTemplate>
</asp:TemplateColumn>

I get the values using:

Dim iEmployeeID As String = _
CType(e.Item.Cells(0).Controls(0), TextBox).Text

Dim sEmployee As String = _
CType(e.Item.FindControl("txtEmployee"), TextBox).Text

Dim sEmployeeGroup As String = _
CType(e.Item.FindControl("cboEmployeeGroup"), _
DropDownList).SelectedValue

New problem: I get the original values from the TextBox or
DropDownList controls and not the new values entered in the TextBox or
selected in the DropDownList (displayed inthe EditItemTemplate part in
edit mode...!!!)

I'm really confused.
It still seems to be the referencing of the template column that I
can't get right.

I've tried:
For Each dgi As DataGridItem In dg.Items
If dgi.ItemType = ListItemType.EditItem Then
...
but it doesn't work

/Morten


Nov 18 '05 #2

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

Similar topics

1
by: cksj | last post by:
I have a link on my web app that opens a pop-up window. In the pop-up window, the user can search for policy information. The result is displayed on a datagrid. The datagrid has 1 hyperlink column...
4
by: chris | last post by:
Hello group, The datagrid I use needs to add a hidden column on demand (only on certain conditions). The sequence of events would be as below: 1) get the dataset(ds) and bind the datagrid(dg) with...
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. ...
4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
2
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
by: me | last post by:
I have a column in my datagrid showing the unique identifier of the rows from the database. I want to hide it but if I switch "visible" off in visual studios property builder for datagrids then...
1
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much...
9
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
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
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
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...
1
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...
1
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.