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

Problems with LoginView and GridView

recently added a LoginView to an existing page, it now looks like
this:

<%@ Page Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeFile="AtPress.aspx.cs" Inherits="AtPress"
Title="Calendars Marked As 'At Press'" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent"
Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="Administrators,Printers">
<ContentTemplate>
<script type="text/javascript"
language="javascript">
function SelectAllCheckboxes(spanChk){
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var
theBox=(spanChk.type=="checkbox")?spanChk:spanChk. children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;

for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" &&
elm[i].id!=theBox.id)
{
//elm[i].click();
if(elm[i].checked!=xState)
elm[i].click();
//elm[i].checked=xState;
}
}
</script>
<strong><span style="font-size: 14pt"><span
style="font-size: 24pt">Calendars Currently Marked As 'At
Press':</span>
<br /><br />
Click checkbox at top of list to select all
items.</span></strong><br />
<asp:GridView ID="GridView1" runat="server"
DataSourceID="CalendarsDataSource" AutoGenerateColumns="False"
DataKeyNames="pk_calendarID">
<Columns>
<asp:BoundField DataField="barcode"
HeaderText="Barcode" SortExpression="barcode" />
<asp:BoundField DataField="received"
HeaderText="Received" SortExpression="received" />
<asp:BoundField DataField="atpress"
HeaderText="At Press" SortExpression="atpress" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox
ID="SelectCalendarCheckbox" runat="server" />
</ItemTemplate>
<HeaderTemplate>
<input id="chkAll"
onclick="javascript:SelectAllCheckboxes(this);" runat="server"
type="checkbox" />
</HeaderTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="btnToHandFinishing" runat="server"
Text="Move To 'At Hand Finishing' Status"
OnClick="btnToHandFinishing_Click" /><br />
<asp:ObjectDataSource ID="CalendarsDataSource"
runat="server" SelectMethod="GetCalendarsByStatusID"
TypeName="CalendarsBLL" OldValuesParameterFormatString="original_{0}">
<SelectParameters>
<asp:Parameter DefaultValue="2"
Name="statusID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="Finishers">
<ContentTemplate>
You Are Not Authorized To View This Page!
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
</asp:Content>

And my code-behind page looks like this:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
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;
using KodakTableAdapters;

public partial class AtPress : System.Web.UI.Page
{
public CalendarsBLL methods = new CalendarsBLL();
protected void Page_Load(object sender, EventArgs e)
{
GridView1.Sort("received", SortDirection.Ascending);
}
protected void btnToHandFinishing_Click(object sender, EventArgs e)
{
//Use this method to copy the items in the
GridViewRowCollection object
//into the specified System.Array object, starting at the
specified index.
//The System.Array object can then be used to access the items
in the collection.

// Copy the items in the Rows collection into an array.
GridViewRow[] rowArray = new GridViewRow[GridView1.Rows.Count];
GridView1.Rows.CopyTo(rowArray, 0);

DataKey key;

// Iterate though the array and display the value in the first
cell of the row.
foreach (GridViewRow row in rowArray)
{
bool result =
((CheckBox)row.FindControl("SelectCalendarCheckbox ")).Checked;
if (result)
{
byte fk_statusID = 3;
DateTime athandfinishing = DateTime.Now;
key = GridView1.DataKeys[row.RowIndex];
int pk_calendarID = ((int)key.Value);
// Get filename
string filename =
methods.GetCalendarFilename(pk_calendarID);
methods.UpdateCalendarAtHandFinishing(fk_statusID,
athandfinishing, pk_calendarID);
// Move Files to "READY_TO_PRINT" folder
string from = "C:\\HTTPPush\\READY_TO_PRINT\\" +
filename;
string to = "C:\\HTTPPush\\PROCESSED\\" + filename;
File.Move(from, to);
// Response.Redirect("~/AtHandFinishing.aspx");
}
}
GridView1.DataBind();
}

}

And I get the following error:

Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'GridView1' does not exist in
the current context

Source Error:

Line 17: protected void Page_Load(object sender, EventArgs e)
Line 18: {
Line 19: GridView1.Sort("received", SortDirection.Ascending);
Line 20: }
Line 21: protected void btnToHandFinishing_Click(object sender,
EventArgs e)

I'm assuming this is due to the GridView not showing for the "current"
user. However, even if I add an if (GridView1) before the
GridView1.Sort it still fails. How can I test to see if GridView1
exists, and if so then execute the code...otherwise ignore the code.
I'm sure there's a simple answer, that I should probably know, but I
can't seem to come up with it. Thanks in advance for any help!

-Sean

Sep 1 '06 #1
0 1895

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

Similar topics

0
by: RedEye | last post by:
Hello, I have been looking for a way to add roles to a LoginView control programmatically and it's not working. I have called the sub at init and load and neither work. Does anyone know what I...
3
by: ad | last post by:
I use a LoginView to authenticate user. Can we set the focus in the UserName or Password of the LoginView?
0
by: Casey | last post by:
Hello. I'm using the loginview control. There are 2 default templates. The 'LoggedInTemplate', and the 'anonymoustemplate'. However, I also have a template (or view?) for the admin role. How do I...
0
by: keithb | last post by:
Using Website | ASP.NET Configuration, I set up a role name Administrators and a user named admin. In my application, I put a LoginView Conrol on my master page. The LoginView control has an...
1
by: Phil | last post by:
I have gridview with a templatefield in which is a loginview. The loginview displays a delete linkbutton for a specified group only. when a record is delete the loginview displays the contents of...
0
by: pagates | last post by:
Hello All, Is there a way to show common "stuff" in the LoginView for all logged in users when using <RoleGroups>? In other words, I have a number of links that all users that log in should...
3
by: =?Utf-8?B?am1obWFpbmU=?= | last post by:
When I put asp controls inside the LoginView it removes the codebehind references so that the page will not build. For example: <asp:LoginView ID="LoginView" runat="server" > <LoggedInTemplate>...
1
by: Morgan Cheng | last post by:
I tried to add a LoginView control in OnClick eventhandler of a button. The code is like below LoginView login = new LoginView(); PlaceHolder1.Controls.Add(login); After run the page, I...
2
by: Jeff | last post by:
Hey ASP.NET 2.0 I'm about to start programming a new website at work. My boss want's me avoid using the Membership system in ASP.NET 2.0 (probably because he don't understand how it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.