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

EditItemTemplate is ignored on edit

1
I have a GridView, and when I click Edit, it is firing the OnRowEditing event ,and I am setting the edititem index, but it keeps displaying the ItemTemplate fields instead of the EditItemTemplate. I have done this before, but I can't figure out why it is ignoring the EditItem Template. I have my code below. Basically, I am storing a "work" table in a session variable, adn I bind that table to the grid, so I don't want to use a datasource.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="gvSOLines" runat="server" AutoGenerateColumns="false" DataKeyNames="POLineNo"
OnRowEditing="gvSOLines_RowEditing"
OnRowUpdating="gvSOLines_RowUpdating" OnRowCancelingEdit="gvSOLines_RowCancelingEdit"
>
<Columns>
<asp:CommandField ButtonType="Link" ShowEditButton="true" ShowCancelButton="true" ShowDeleteButton="true" SelectText="Attributes" />
<asp:TemplateField HeaderText="Line">
<ItemTemplate>
<asp:Label id="lblPOLineNo" Runat="Server" Text='<%# Eval("POLineNo") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer Item">
<ItemTemplate>
<asp:Label id="lblCustItem" Runat="Server" Text='<%# Eval("CustItem") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%# Bind("Quantity") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="U/M">
<ItemTemplate>
<asp:Label ID="lblUnitMeasID" runat="server" Text='<%#Bind("UnitMeasID") %>' />
<asp:Label ID="lblUOM" runat="server" Text='<%#Bind("UMKey") %>' visible="false"/>
<asp:Label ID="lblItemID" runat="server" Text='<%#Bind("ItemID") %>' visible="false"/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlUOM" DataTextField="UnitMeasID" DataValueField="UnitMeasKey" runat="server" />
<asp:Label ID="lblUOM" runat="server" Text='<%#Bind("UMKey") %>' visible="false"/>
<asp:Label ID="lblItemID" runat="server" Text='<%#Bind("ItemID") %>' visible="false"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Price">
<ItemTemplate>
<asp:Label id="lblPrice" Runat="Server" Text='<%# Eval("Price") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:Label id="lblPrice" Runat="Server" Text='<%# Eval("Price") %>'/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Extd Amt">
<ItemTemplate>
<asp:Label id="lblExtdAmt" Runat="Server" Text='<%# Eval("ExtdAmt") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:Label id="lblExtdAmt" Runat="Server" Text='<%# Eval("ExtdAmt") %>'/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Req Date">
<ItemTemplate>
<asp:Label id="lblRequestDate" Runat="Server" Text='<%# Eval("RequestDate") %>'/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtRequestDate" Runat="Server" Text='<%# Eval("RequestDate") %>' Width="50px"/>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>





Imports System.Data

Partial Class test
Inherits System.Web.UI.Page


Sub gvSOLines_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs)
gvSOLines.EditIndex = -1
Call BindLines()
End Sub

Sub gvSOLines_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
gvSOLines.SelectedIndex = e.NewEditIndex
Call BindLines()
End Sub

Sub gvSOLines_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
'Dim row As GridViewRow = gvSOLines.Rows(e.RowIndex)
Dim rowIndex As Integer = e.RowIndex
End Sub

Sub BindLines()

'Bind order lines to gridview
Try
Dim dtSOLines As DataTable = Session("SOLines")
gvSOLines.DataSource = dtSOLines
gvSOLines.DataBind()
Catch ex As Exception
End Try

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
Dim dtSOLines As DataTable = New DataTable("Item")

dtSOLines.Columns.Add("ItemID", GetType(String))
dtSOLines.Columns.Add("Price", GetType(Decimal))
dtSOLines.Columns.Add("Quantity", GetType(Decimal))
dtSOLines.Columns.Add("Description", GetType(String))
dtSOLines.Columns.Add("POLineNo", GetType(Integer))
dtSOLines.Columns.Add("UnitMeasID", GetType(String))
dtSOLines.Columns.Add("RequestDate", GetType(String))
dtSOLines.Columns.Add("TaxClassID", GetType(String))
dtSOLines.Columns.Add("UserFld1", GetType(String))
dtSOLines.Columns.Add("UserFld2", GetType(String))
dtSOLines.Columns.Add("CustItem", GetType(String))
dtSOLines.Columns.Add("UMKey", GetType(Decimal))
dtSOLines.Columns.Add("ExtdAmt", GetType(Decimal))
dtSOLines.Columns.Add("ItemKey", GetType(Integer))

'Attributes
dtSOLines.Columns.Add("WidthE", GetType(Decimal))
dtSOLines.Columns.Add("WidthM", GetType(Decimal))
dtSOLines.Columns.Add("Core", GetType(Integer))
dtSOLines.Columns.Add("DiameterE", GetType(Decimal))
dtSOLines.Columns.Add("DiameterM", GetType(Decimal))
dtSOLines.Columns.Add("CustPartNo", GetType(String))
dtSOLines.Columns.Add("AppLevel", GetType(String))
dtSOLines.Columns.Add("Sides", GetType(Integer))
dtSOLines.Columns.Add("Orientation", GetType(String))
dtSOLines.Columns.Add("Notes", GetType(String))

Dim row As DataRow = dtSOLines.NewRow()

row("POLineNo") = 1
row("ItemID") = "ITEM1"
row("Description") = "Item Description"
row("CustItem") = "CUSTITEM"
row("Quantity") = 5
row("UMKey") = 1
row("UnitMeasID") = "Each"
row("Price") = 100
row("ExtdAmt") = 500
row("RequestDate") = "03/07/2008"
row("TaxClassID") = ""
row("UserFld1") = ""
row("UserFld2") = ""
row("ItemKey") = 1

'Attributes
row("WidthE") = 0
row("WidthM") = 0
row("Core") = 0
row("DiameterE") = 0
row("DiameterM") = 0
row("CustPartNo") = ""
row("AppLevel") = ""
row("Sides") = 0
row("Orientation") = ""
row("Notes") = ""

'Save Attributes for this line
'Call SaveLineAttrib(iPOLine)

dtSOLines.Rows.Add(row)

Session("SOLines") = dtSOLines

BindLines()
End If
End Sub
End Class
Feb 12 '08 #1
0 1117

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: VB Programmer | last post by:
I have a datagrid with a dropdownlist in it. As I understand it, the ItemTemplate section represents the cell when not in edit mode and the EditItemTemplate section represents the cell when in...
3
by: rkbnair | last post by:
I have defined <ItemTemplate>XXXX</ItemTemplate> and <EditItemTemplate>XXXX</EditItemTemplate> in an asp page. How can I make the EditItemTemplate item visible (I mean through the program)
1
by: Dan Sikorsky | last post by:
My ASP.Net 2.0 FormView has an EditItemTemplate, an InsertItemTemplate and an ItemTemple. When the page first loads, the ItemTemplate shows with an Edit button. If the user clicks the Edit button,...
0
by: Jim in Arizona | last post by:
I've got a datalist with an ItemTemplate and EditItemTemplate. Its strange (to me), but when I have some records showing (data list items, if you will), and I click the Edit button on the first...
0
by: Jim in Arizona | last post by:
Using a datalist, I have an ItemTemplate and an EditItemTemplate. The default view shows several records within the ItemTemplate based on a basic SELECT statement. When the user presses the Edit...
0
by: Dan | last post by:
Issue making textbox visible based on specific input from a radio button list in an EditItemTemplate I want to setup a gridview that when in edit mode and when the user selects "Other" from a...
1
by: news.microsoft.com | last post by:
I have been working some on a gridview to incorporate the ability to edit data for a row. I set up TemplateFields with EditItemTemplates to incorporate the text box controls I want for editing, but...
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...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.