Press Ctrl-zero to enter a null value into the Open Table view in SQL Server Management Studio.
 
To go before the last line in the previous post:

DECLARE @Results varchar(255)
DECLARE StudentResults CURSOR FOR SELECT ItemID, ISNULL(Rating, '')
FROM @StudentResults FOR UPDATE OF Results
OPEN StudentResults
FETCH NEXT FROM StudentResults INTO @ItemID, @Rating
WHILE @@FETCH_STATUS = 0
BEGIN
 SET @Results = ''

 SELECT @Results = COALESCE(@Results, '') + e.ElementTitle + ' ' + m.MarkCode + '<br/>'
 FROM tblAssessmentMarkbook m INNER JOIN tblElements e ON e.ElementID=m.ElementID
 WHERE m.AssessItemID=@AssessItemID AND m.StudentID=@StudentID
 AND m.MarkCode IS NOT NULL AND m.MarkCode != ''

 UPDATE @StudentResults SET Results = @Results + @Rating WHERE CURRENT OF StudentResults
 FETCH NEXT FROM StudentResults INTO @AssessItemID, @Rating
END
CLOSE StudentResults
DEALLOCATE StudentResults
 
ALTER PROCEDURE [dbo].[spStoredProcName]
@StudentID varchar(10),
@ItemID int
AS

DECLARE @StudentResults TABLE(ItemName varchar(100), DateItemDue smalldatetime, StudentID varchar(10), DateSubmitted smalldatetime, Rating varch(3), Results varchar(255))
INSERT INTO @StudentResults

SELECT i.ItemName, i.DateItemDue, r.StudentID, r.DateSubmitted, r.Rating, '' AS Results 
 FROM tblAssessmentItem i 
 LEFT OUTER JOIN tblStudentAssessItemReg r ON r.ItemID=i.ItemID
 AND r.StudentID=@StudentID
 WHERE i.ItemID = @ItemID
 ORDER BY i.DateItemDue

SELECT * FROM @StudentResults
 
 
 
The GridView control supports updating data, but not inserting.  This can be achieved though by adding insert controls to the header or footer of the gridveiw, and on clicking the insert button call the data source insert( routine from code.  You can also show the header or footer conditionaly from code.  Here is some example code:

<asp:GridView ... ShowHeader='<%# CanEdit() %>'>

<HeaderTemplate>
Text <asp:TextBox ID="TextBoxTitle" runat="server" ValidationGroup="insertgroup"></asp:TextBox>
URL <asp:TextBox ID="TextBoxURL" runat="server" ValidationGroup="insertgroup"></asp:TextBox>
<asp:CheckBox ID="CheckBoxNewWindow" runat="server" ToolTip="New Window" Checked="true"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBoxTitle" ErrorMessage="Text Required" Display="Dynamic" ValidationGroup="insertgroup"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBoxURL" ErrorMessage="URL Required" Display="Dynamic" ValidationGroup="insertgroup"></asp:RequiredFieldValidator>
<asp:LinkButton ID="LinkButtonNew" runat="server" OnClick="New_Click" ValidationGroup="insertgroup"> Insert</asp:LinkButton>
</HeaderTemplate>

protected Boolean CanEdit()
{
return (ViewState["CanEdit"] != null && (Boolean)ViewState["CanEdit"] == true) ? true : false;
}

protectedvoid New_Click(object sender, EventArgs e)
{
TextBox title = (TextBox)GridView1.HeaderRow.FindControl("TextBoxTitle");
TextBox url = (TextBox)GridView1.HeaderRow.FindControl("TextBoxURL");
CheckBox newwindow = (CheckBox)GridView1.HeaderRow.FindControl("CheckBoxNewWindow");
SqlDataSource1.InsertParameters[
"LinkTitle"].DefaultValue = title.Text;
SqlDataSource1.InsertParameters[
"LinkURL"].DefaultValue = url.Text;
SqlDataSource1.InsertParameters[
"NewWindow"].DefaultValue = newwindow.Checked.ToString();
SqlDataSource1.Insert();
//change gridview to select mode
GridView1.EditIndex = -1;
}
 
You can use the default membership provider database installed with .NET 2 (aspnetdb) to provide role based membership to your ASP.NET apps.  First enable the role manager in web.config (this can be set up to use another database/provider), then you can control permissions to locations in the web.config file or in your code.

<system.web>
<authentication mode="Forms" />
<roleManager Enabled="true" />
</system.web>

<location pathe="FileOrFolderName">
<system.web>
<authorozation>
<allow roles="NewRole" />
<deny users="*" />
</authorization>
</location>

using System.Web.Security;
Roles.CreateRole("NewRole");
Roles.IsUSerInRole(User.Identity.Name, "NewRole");
 
Works with Bing, Google and Yahoo, sweet.
http://www.microsoft.com/web/spotlight/seo/?appid=10990002
 
User Controls are a great way to break your code up into functional parts for code reuse, or just to seperate a complex page into manageable bits.  To create a user control in Visual Studio add a new item and select Web User Control.  Add your ASP.NET controls, and then add public parameters and methods to the control's code-behid like this:

public
partial class MyControl : System.Web.UI.UserControl
{
public String MyParam
{
get
{
return (String)ViewState["MyParam"];
}
set
{
ViewState[
"MyParam"] = value;
}
}

protected void Page_Load(object sender, EventArgs e)
{
}

public void MyMethod()
{
//Do something here...
}
}

To use the control in a page you need to register a tag for it at the top of youe page immediately after the @Page reference, and then you can add the control as follows:

<%@Register TagPrefix="bc" TagName="MyControl" Src="MyControl.ascx" %>

<bc:MyControl ID="MyControl1" runat="Server" MyParam="value"></bc:MyControl>

To call a method of the control from the referring pages code behind, do this:

MyControl myControl = (MyControl)FormView1.FindControl("MyControl1");
myControl.Method();
 
If you need to get the last inerted ID when you are using a SqlDataSource control, there is an easy way to achieve this.  Add SET @param=SCOPE_IDENTITY() to the end of your insert command and add an insert parameter with direction = output like this:

<asp:Parameter Name="param" Type="Int32" Direction="Output" />

Then to use it add an OnInserted event to your SqlDataSource and acess the value in your code-behind like this:

protectedvoid SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
String id
 = e.Command.Parameters["@param"].Value.ToString();
}