470,612 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

EditItemTemplate is ignored on edit

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>
<form id="form1" runat="server">
<asp:GridView ID="gvSOLines" runat="server" AutoGenerateColumns="false" DataKeyNames="POLineNo"
OnRowUpdating="gvSOLines_RowUpdating" OnRowCancelingEdit="gvSOLines_RowCancelingEdit"
<asp:CommandField ButtonType="Link" ShowEditButton="true" ShowCancelButton="true" ShowDeleteButton="true" SelectText="Attributes" />
<asp:TemplateField HeaderText="Line">
<asp:Label id="lblPOLineNo" Runat="Server" Text='<%# Eval("POLineNo") %>'/>
<asp:TemplateField HeaderText="Customer Item">
<asp:Label id="lblCustItem" Runat="Server" Text='<%# Eval("CustItem") %>'/>
<asp:TemplateField HeaderText="Quantity">
<asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity") %>' />
<asp:Label ID="lblQuantity" runat="server" Text='<%# Bind("Quantity") %>' />
<asp:TemplateField HeaderText="U/M">
<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"/>
<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"/>
<asp:TemplateField HeaderText="Unit Price">
<asp:Label id="lblPrice" Runat="Server" Text='<%# Eval("Price") %>'/>
<asp:Label id="lblPrice" Runat="Server" Text='<%# Eval("Price") %>'/>
<asp:TemplateField HeaderText="Extd Amt">
<asp:Label id="lblExtdAmt" Runat="Server" Text='<%# Eval("ExtdAmt") %>'/>
<asp:Label id="lblExtdAmt" Runat="Server" Text='<%# Eval("ExtdAmt") %>'/>
<asp:TemplateField HeaderText="Req Date">
<asp:Label id="lblRequestDate" Runat="Server" Text='<%# Eval("RequestDate") %>'/>
<asp:TextBox id="txtRequestDate" Runat="Server" Text='<%# Eval("RequestDate") %>' Width="50px"/>

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
Dim dtSOLines As DataTable = Session("SOLines")
gvSOLines.DataSource = dtSOLines
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))

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

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)


Session("SOLines") = dtSOLines

End If
End Sub
End Class
Feb 12 '08 #1
0 993

Post your reply

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

Similar topics

2 posts views Thread by VB Programmer | last post: by
3 posts views Thread by rkbnair | last post: by
reply views Thread by Jim in Arizona | last post: by
reply views Thread by Jim in Arizona | last post: by
1 post views Thread by news.microsoft.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.