Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 3rd, 2008, 12:11 AM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Gridview with only one row

I got a gridview with template fields.The first field is a dropdown list and second one is a label and third and 4th fields the user need to enter.After the enter button is pressed on the last field a new row is to be created with ddlist filled from the database.So my question is how can we make a gridview contain only one row in page load...

AMR
 
Old March 3rd, 2008, 09:19 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Set the PageSize attribute to 1.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 3rd, 2008, 12:37 PM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear friend,

I am not able to sort it out even i give that attribute 1...

AMR
 
Old March 3rd, 2008, 12:54 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Something like this should work:

if(!Page.IsPostBack)
{
    gv.PageSize = 1;
    gv.DataSource = <datasource>;
    gv.DataBind();
}

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old March 4th, 2008, 11:00 PM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear parson,
its not working parson.The thing is I got 3 records in database and the grid is displaying 3 records eventhou i give pagesize attribute as 1.and the three textboxes are not from the database.they are not databound...

AMR
 
Old March 5th, 2008, 09:27 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Then why are your controls even in the GridView at all? The generated GridView is based soley off of values that are provided from controls that do not need to be connected to the datasource. Why not move these controls out of the gridview all together?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView - Skipping a Row gothael ASP.NET 2.0 Basics 1 July 18th, 2008 10:02 AM
Gridview with only one row mallikalapati ASP.NET 2.0 Professional 0 February 25th, 2008 06:46 AM
Getting a GridView Row to highlight gcm_uk ASP.NET 2.0 Basics 0 May 1st, 2007 05:55 AM
Getting Data from selected row in gridview JoinTTT ASP.NET 2.0 Professional 3 April 17th, 2007 02:14 AM
GridView and Row Index itwebguy .NET Framework 2.0 1 October 16th, 2006 04:18 PM





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