Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 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 July 26th, 2007, 04:28 PM
Registered User
 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes the SP returns the record properly. I just checked again.

The page with the UI has the following code behind. It is on the data bind of the details view where this issue starts (in red).

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtEndDate.SelectedDate = DateTime.Now;
            txtStartDate.SelectedDate = DateTime.Now.AddDays(-(Convert.ToInt32(Globals.Settings.Tasks.DefaultDat eRangeInDays)));
            dvTaskDetails.Visible = false;

        }
    }
    protected void btnRefreshView_Click(object sender, EventArgs e)
    {
        gvTasks.DataBind();
    }
    protected void gvTasks_SelectedIndexChanged(object sender, EventArgs e)
    {
        getTaskDetail();
    }

    private void getTaskDetail()
    {
            dvTaskDetails.ChangeMode(DetailsViewMode.Edit);
            dvTaskDetails.DataBind();
This has the ID value from the grid. It should grab the record.

            dvTaskDetails.Visible = true;
    }

Am I missing something obvious? I have a suspicion I might be.

--
Tara G Deschenes
Technimedia LLC
 
Old July 26th, 2007, 04:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What does the code look like that creates the reader and passes it to GetTaskFromReader?

Maybe you're not calling the right procedure or sending it incorrect parameters?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old July 31st, 2007, 10:30 AM
Registered User
 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a quick update on this situation. I reviewed all my code and was missing some key lines. Ugh.

    public override TaskDetails GetTaskById(int taskId)
        {
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("Tasks_GetTaskById", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@TaskId", SqlDbType.Int).Value = taskId;
                cn.Open();
                IDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                    return GetTaskFromReader(reader);
                else
                    return null;
            }
        }

That fixed it. I didn't see this in the book (for some reason) and had to download the online version of the code and compare the two. Then I found it.

That's what happens when you stare at something for too long without regular breaks!!

Thanks again for the attention and conversation. Sometimes it just helps to vent. :)

--
Tara G Deschenes
Technimedia LLC
 
Old July 31st, 2007, 11:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Tara,

Great, glad it's working now....

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
The IDataReader....a suggestion. Tremmorkeep BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 February 22nd, 2008 11:37 AM
Type Ahead Drop Down List kdkcchoco ASP.NET 1.0 and 1.1 Professional 43 February 20th, 2007 03:56 PM





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