Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 13th, 2011, 07:40 PM
Registered User
 
Join Date: Feb 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Customizing GridView Columns - CreateDateTime

Hi

Problem: when i select the item in DropDownList, the records are displayed but the "CreateDateTime" column is not displayed.
the Grid View Displays - Title,Authorized,Id,Delete. Displays "Id" instead of CreateDateTime" column.

Review.aspx code: ---------------------------------------


<%@ Page Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="true" CodeFile="Reviews.aspx.cs" Inherits="Management_Reviews" Title="Planet Wrox - Management - Reviews" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="Id">
<asp:ListItem Value="">Please make a selection</asp:ListItem>
</asp:DropDownList>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" DataSourceID="SqlDataSource2">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Id"
DataNavigateUrlFormatString="AddEditReviews.aspx?I d={0}" DataTextField="Title"
HeaderText="Title" />
<asp:TemplateField HeaderText="Authorized" SortExpression="Authorized">

<ItemTemplate>
<asp:Label ID="lblAuthorized" runat="server" Text='<%# GetBooleanText(Eval("Authorized")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
ReadOnly="True" SortExpression="Id" />

<asp:CommandField HeaderText="Delete" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"

SelectCommand="SELECT [Id], [Title], [CeateDateTime], [Authorized] FROM [Review] WHERE ([GenreId] = @GenreId)"
DeleteCommand="DELETE FROM [Review] WHERE [Id] = @Id"
InsertCommand="INSERT INTO [Review] ([Title], [CeateDateTime], [Authorized]) VALUES (@Title, @CeateDateTime, @Authorized)"
UpdateCommand="UPDATE [Review] SET [Title] = @Title, [CeateDateTime] = @CeateDateTime, [Authorized] = @Authorized WHERE [Id] = @Id">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="GenreId"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter DbType="Date" Name="CeateDateTime" />
<asp:Parameter Name="Authorized" Type="Boolean" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter DbType="Date" Name="CeateDateTime" />
<asp:Parameter Name="Authorized" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
SelectCommand="SELECT [Id], [Name] FROM [Genre] ORDER BY [SortOrder]">
</asp:SqlDataSource>

</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

-------------------------------------------------------------

code behind --------------file code--------------------


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Management_Reviews : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected string GetBooleanText(object booleanValue) {
bool authorized = (bool)booleanValue;
if (authorized){return "Yes"; }
else
{return "No";}
}
}


please tell me why is it not displaying "CreateDateTime".

with regards
sandeep
 
Old March 13th, 2011, 10:42 PM
Registered User
 
Join Date: Feb 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default i corrected it

spellings for "CreateDateTime" were wrong and i was feeding "(0:g)" instead of "{0:g}"





Similar Threads
Thread Thread Starter Forum Replies Last Post
web error running chap 12 Customizing GridView Columns Onypips BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 March 7th, 2011 04:06 PM
Ch12 - TIO - Customizing GridView Controls p404 Step 9 & 10 AppleBoy BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 February 17th, 2011 10:33 AM
Chapter 12, CreateDateTime problem Wilfredo Rosado BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 June 5th, 2010 02:11 AM
Chapter 12, Customizing GridView Columns Wilfredo Rosado BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 June 4th, 2010 03:46 PM
Need to get value of gridview template columns for kmh030 ASP.NET 2.0 Professional 1 January 6th, 2007 11:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.