I've tried a number of variations, including setting the lable text in the page load event, but this is what I have currently, which is in a RowUpdating event of a GridView control. First the code file:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class regGridSess : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.SqlDataSourceGrid.ConnectionString = "Dsn=MISDATA;uid="
+ Session["uid"].ToString()
+ ";pwd="
+ Session["pwd"].ToString();
Label bannerLabel = (Label)Master.FindControl("bannerText");
bannerLabel.Text = "Registrations for a Session";
if (!IsPostBack) return; // First time in page code.
// Form has been posted.
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text.PadLeft(6, Char.Parse("0"));
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
LabelEditMessage.Text = "test";
e.Cancel = true;
}
}
Here is the ASP source:
<%@ Page Language="C#" MasterPageFile="~/MISDefault.master" AutoEventWireup="true" CodeFile="regGridSess.aspx.cs" Inherits="regGridSess" Title="Registration Grid for a Session" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Session Number:"></asp:Label><asp:TextBox
ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox><asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Text="Show Registrations" />
<asp:RegularExpressionValidator
ID="sessNumValidator" runat="server" ControlToValidate="TextBox1" ErrorMessage="Session number must be one to 6 numeric digits"
ValidationExpression="\d{1,6}"></asp:RegularExpressionValidator>
<asp:SqlDataSource ID="SqlDataSourceGrid" runat="server" ConnectionString="<%$ ConnectionStrings:MisWeb %>"
DeleteCommand='DELETE FROM "Register" WHERE "Sess_Num" = ? AND "Ptcpnt_SSN" = ?'
InsertCommand='INSERT INTO "Register" ("Sess_Num", "Ptcpnt_SSN", "Credit_Type", "Pay_Code", "Stat", "ShowedUp", "Confirmation_Notice", "Fee_Stat", "Pay_Date", "Pay_Amt", "Credit_Hours", "District_PO", "Credit_Card_Num", "Credit_Card_Type", "Credit_Card_Name", "Credit_Card_Expiration", "Check_Num", "Cash_Rcpt_Num", "Cert_Printed", "Fee_Amt", "Refund_Amt", "Date_Billed", "Dist_Code", "Camp_Code", "Billing_Name", "Billing_Addr_Line_1", "Billing_Addr_Line_2", "Billing_City", "Billing_State", "Billing_Zip") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
ProviderName="<%$ ConnectionStrings:MisWeb.ProviderName %>" SelectCommand='SELECT "Sess_Num", "Ptcpnt_SSN", "Credit_Type", "Pay_Code", "Stat", "ShowedUp", "Confirmation_Notice", "Fee_Stat", "Pay_Date", "Pay_Amt", "Credit_Hours", "Registration_Date", "District_PO", "Credit_Card_Num", "Credit_Card_Type", "Credit_Card_Name", "Credit_Card_Expiration", "Web_Registration", "Check_Num", "Cash_Rcpt_Num", "Cert_Printed", "Inv_WO", "Fee_Amt", "Refund_Amt", "Date_Billed", "Dist_Code", "Camp_Code", "DropCancel_Date", "Billing_Name", "Billing_Addr_Line_1", "Billing_Addr_Line_2", "Billing_City", "Billing_State", "Billing_Zip" FROM "Register" WHERE "Sess_Num" = ? '
UpdateCommand='UPDATE "Register" SET "Credit_Type" = ?, "Pay_Code" = ?, "Stat" = ?, "ShowedUp" = ?, "Confirmation_Notice" = ?, "Fee_Stat" = ?, "Pay_Date" = ?, "Pay_Amt" = ?, "Credit_Hours" = ?, "District_PO" = ?, "Credit_Card_Type" = ?, "Credit_Card_Name" = ?, "Credit_Card_Expiration" = ?, "Check_Num" = ?, "Cash_Rcpt_Num" = ?, "Cert_Printed" = ?, "Fee_Amt" = ?, "Refund_Amt" = ?, "Date_Billed" = ?, "Dist_Code" = ?, "Camp_Code" = ?, "Billing_Name" = ?, "Billing_Addr_Line_1" = ?, "Billing_Addr_Line_2" = ?, "Billing_City" = ?, "Billing_State" = ?, "Billing_Zip" = ? WHERE "Sess_Num" = ? AND "Ptcpnt_SSN" = ?'>
<DeleteParameters>
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Credit_Type" Type="String" />
<asp:Parameter Name="Pay_Code" Type="String" />
<asp:Parameter Name="Stat" Type="String" />
<asp:Parameter Name="ShowedUp" Type="String" />
<asp:Parameter Name="Confirmation_Notice" Type="String" />
<asp:Parameter Name="Fee_Stat" Type="String" />
<asp:Parameter Name="Pay_Date" Type="DateTime" />
<asp:Parameter Name="Pay_Amt" Type="Decimal" />
<asp:Parameter Name="Credit_Hours" Type="String" />
<asp:Parameter Name="District_PO" Type="String" />
<asp:Parameter Name="Credit_Card_Type" Type="String" />
<asp:Parameter Name="Credit_Card_Name" Type="String" />
<asp:Parameter Name="Credit_Card_Expiration" Type="String" />
<asp:Parameter Name="Check_Num" Type="String" />
<asp:Parameter Name="Cash_Rcpt_Num" Type="String" />
<asp:Parameter Name="Cert_Printed" Type="String" />
<asp:Parameter Name="Fee_Amt" Type="Decimal" />
<asp:Parameter Name="Refund_Amt" Type="Decimal" />
<asp:Parameter Name="Date_Billed" Type="DateTime" />
<asp:Parameter Name="Dist_Code" Type="String" />
<asp:Parameter Name="Camp_Code" Type="String" />
<asp:Parameter Name="Billing_Name" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_1" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_2" Type="String" />
<asp:Parameter Name="Billing_City" Type="String" />
<asp:Parameter Name="Billing_State" Type="String" />
<asp:Parameter Name="Billing_Zip" Type="String" />
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" DefaultValue="000000" Name="Sess_Num"
PropertyName="Text" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="Sess_Num" Type="String" />
<asp:Parameter Name="Ptcpnt_SSN" Type="String" />
<asp:Parameter Name="Credit_Type" Type="String" />
<asp:Parameter Name="Pay_Code" Type="String" />
<asp:Parameter Name="Stat" Type="String" />
<asp:Parameter Name="ShowedUp" Type="String" />
<asp:Parameter Name="Confirmation_Notice" Type="String" />
<asp:Parameter Name="Fee_Stat" Type="String" />
<asp:Parameter Name="Pay_Date" Type="DateTime" />
<asp:Parameter Name="Pay_Amt" Type="Decimal" />
<asp:Parameter Name="Credit_Hours" Type="String" />
<asp:Parameter Name="District_PO" Type="String" />
<asp:Parameter Name="Credit_Card_Num" Type="String" />
<asp:Parameter Name="Credit_Card_Type" Type="String" />
<asp:Parameter Name="Credit_Card_Name" Type="String" />
<asp:Parameter Name="Credit_Card_Expiration" Type="String" />
<asp:Parameter Name="Check_Num" Type="String" />
<asp:Parameter Name="Cash_Rcpt_Num" Type="String" />
<asp:Parameter Name="Cert_Printed" Type="String" />
<asp:Parameter Name="Fee_Amt" Type="Decimal" />
<asp:Parameter Name="Refund_Amt" Type="Decimal" />
<asp:Parameter Name="Date_Billed" Type="DateTime" />
<asp:Parameter Name="Dist_Code" Type="String" />
<asp:Parameter Name="Camp_Code" Type="String" />
<asp:Parameter Name="Billing_Name" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_1" Type="String" />
<asp:Parameter Name="Billing_Addr_Line_2" Type="String" />
<asp:Parameter Name="Billing_City" Type="String" />
<asp:Parameter Name="Billing_State" Type="String" />
<asp:Parameter Name="Billing_Zip" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceCredit" runat="server" ConnectionString="<%$ ConnectionStrings:MisWeb %>"
ProviderName="<%$ ConnectionStrings:MisWeb.ProviderName %>" SelectCommand="SELECT [credit_type_code], [credit_type_descr] FROM [Credit_Type] WHERE ([Credit_Type_Active] = ?) ORDER BY [credit_type_code]">
<SelectParameters>
<asp:Parameter DefaultValue="Y" Name="Credit_Type_Active" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="LabelEditMessage" runat="server" ForeColor="Red" Width="1040px">xxx</asp:Label><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Sess_Num,Ptcpnt_SSN"
DataSourceID="SqlDataSourceGrid" EmptyDataText="There are no data records to display."
GridLines="Vertical" Visible="False" AllowSorting="True" OnRowUpdating="GridView1_RowUpdating">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Sess_Num" HeaderText="Sess_Num" ReadOnly="True" SortExpression="Sess_Num" Visible="False" />
<asp:BoundField DataField="Ptcpnt_SSN" HeaderText="Ptcpnt_SSN" ReadOnly="True" SortExpression="Ptcpnt_SSN" />
<asp:TemplateField HeaderText="Credit_Type" SortExpression="Credit_Type">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList7" runat="server" DataSourceID="SqlDataSourceCredit"
DataTextField="credit_type_descr" DataValueField="credit_type_code" SelectedValue='<%# Bind("Credit_Type") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Credit_Type") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pay_Code" SortExpression="Pay_Code">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server"
DataTextField="Pay_Code" DataValueField="Pay_Code" SelectedValue='<%# Bind("Pay_Code") %>'>
<asp:ListItem Selected="True" Value=" ">No Fee</asp:ListItem>
<asp:ListItem Value="D">District</asp:ListItem>
<asp:ListItem Value="I">Individual</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Pay_Code") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Stat" SortExpression="Stat">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList6" runat="server"
DataTextField="Stat" DataValueField="Stat" SelectedValue='<%# Bind("Stat") %>'>
<asp:ListItem Selected="True" Value=" ">Unconfirmed</asp:ListItem>
<asp:ListItem Value="F">Confirmed</asp:ListItem>
<asp:ListItem Value="D">Dropped</asp:ListItem>
<asp:ListItem Value="C">Cancelled</asp:ListItem>
<asp:ListItem Value="L">Closed</asp:ListItem>
<asp:ListItem Value="W">Wait List</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Stat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ShowedUp" SortExpression="ShowedUp">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataTextField="ShowedUp" DataValueField="ShowedUp" SelectedValue='<%# Bind("ShowedUp") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ShowedUp") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Confirmation_Notice" SortExpression="Confirmation_Notice">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataTextField="Confirmation_Notice" DataValueField="Confirmation_Notice" SelectedValue='<%# Bind("Confirmation_Notice") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Confirmation_Notice") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fee_Stat" SortExpression="Fee_Stat">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList8" runat="server"
DataTextField="Fee_Stat" DataValueField="Fee_Stat" SelectedValue='<%# Bind("Fee_Stat") %>'>
<asp:ListItem Selected="True" Value="F">Free</asp:ListItem>
<asp:ListItem Value="R">Refund</asp:ListItem>
<asp:ListItem Value="P">Paid</asp:ListItem>
<asp:ListItem Value="B">Refund (Cancel)</asp:ListItem>
<asp:ListItem Value="T">Transfer</asp:ListItem>
<asp:ListItem Value="U">Unpaid</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Fee_Stat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Pay_Date" HeaderText="Pay_Date" SortExpression="Pay_Date" />
<asp:BoundField DataField="Pay_Amt" HeaderText="Pay_Amt" SortExpression="Pay_Amt" />
<asp:BoundField DataField="Credit_Hours" HeaderText="Credit_Hours" SortExpression="Credit_Hours" />
<asp:BoundField DataField="Registration_Date" HeaderText="Registration_Date" SortExpression="Registration_Date" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="District_PO" HeaderText="District_PO" SortExpression="District_PO" />
<asp:BoundField DataField="Credit_Card_Num" HeaderText="Credit_Card_Num" SortExpression="Credit_Card_Num" Visible="False" />
<asp:BoundField DataField="Credit_Card_Type" HeaderText="Credit_Card_Type" SortExpression="Credit_Card_Type" />
<asp:BoundField DataField="Credit_Card_Name" HeaderText="Credit_Card_Name" SortExpression="Credit_Card_Name" />
<asp:BoundField DataField="Credit_Card_Expiration" HeaderText="Credit_Card_Expiration"
SortExpression="Credit_Card_Expiration" />
<asp:BoundField DataField="Web_Registration" HeaderText="Web_Registration" SortExpression="Web_Registration" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Check_Num" HeaderText="Check_Num" SortExpression="Check_Num" />
<asp:BoundField DataField="Cash_Rcpt_Num" HeaderText="Cash_Rcpt_Num" SortExpression="Cash_Rcpt_Num" />
<asp:TemplateField HeaderText="Cert_Printed" SortExpression="Cert_Printed">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server"
DataTextField="Cert_Printed" DataValueField="Cert_Printed" SelectedValue='<%# Bind("Cert_Printed") %>'>
<asp:ListItem Selected="True" Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Cert_Printed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Inv_WO" HeaderText="Inv_WO" SortExpression="Inv_WO" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Fee_Amt" HeaderText="Fee_Amt" SortExpression="Fee_Amt" />
<asp:BoundField DataField="Refund_Amt" HeaderText="Refund_Amt" SortExpression="Refund_Amt" />
<asp:BoundField DataField="Date_Billed" HeaderText="Date_Billed" SortExpression="Date_Billed" />
<asp:BoundField DataField="Dist_Code" HeaderText="Dist_Code" SortExpression="Dist_Code" />
<asp:BoundField DataField="Camp_Code" HeaderText="Camp_Code" SortExpression="Camp_Code" />
<asp:BoundField DataField="DropCancel_Date" HeaderText="DropCancel_Date" SortExpression="DropCancel_Date" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Billing_Name" HeaderText="Billing_Name" SortExpression="Billing_Name" />
<asp:BoundField DataField="Billing_Addr_Line_1" HeaderText="Billing_Addr_Line_1"
SortExpression="Billing_Addr_Line_1" />
<asp:BoundField DataField="Billing_Addr_Line_2" HeaderText="Billing_Addr_Line_2"
SortExpression="Billing_Addr_Line_2" />
<asp:BoundField DataField="Billing_City" HeaderText="Billing_City" SortExpression="Billing_City" />
<asp:BoundField DataField="Billing_State" HeaderText="Billing_State" SortExpression="Billing_State" />
<asp:BoundField DataField="Billing_Zip" HeaderText="Billing_Zip" SortExpression="Billing_Zip" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</asp:Content>