Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
  #11 (permalink)  
Old August 24th, 2012, 04:07 AM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 29
Thanks: 11
Thanked 0 Times in 0 Posts
Default

sir when i used .HeaderText an error says "HeaderText is not a member of System.Web.Ui.WebControls.TableCell." i changed it to .Text and it worked. thanks for the code! Now it's running :)
  #12 (permalink)  
Old August 24th, 2012, 04:18 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're correct. My mistake. I updated the original post as well.

Quote:
May I ask what you're trying to accomplish? Is there any reason why you're not explicitly defining the columns in the GridView and instead rely on run-time discovery? Also any reason for not using the EntityDataSource to handle binding, paging and sorting for you?
Want to comment on this? I am wondering why you're doing what you're doing...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #13 (permalink)  
Old August 28th, 2012, 08:45 PM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 29
Thanks: 11
Thanked 0 Times in 0 Posts
Default

I dont know how to control the binding in the datasource controls using if-else. is there a way on how to manipulate the datasource controls programmatically? Im using the things i learned from your book in creating an Online Alumni System for our school. Our College hired me as their web developer and web administrator. thanks for the things i learned from your book and i hope you publish more in the future :)
  #14 (permalink)  
Old August 29th, 2012, 04:27 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
is there a way on how to manipulate the datasource controls programmatically?
Yes, but you need to provide more info about what it is you want to do.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #15 (permalink)  
Old August 29th, 2012, 04:29 AM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 29
Thanks: 11
Thanked 0 Times in 0 Posts
Default

for example you can program the datasource control to bind to a specific table based on the arguments in the if-else statement. is that possible?
  #16 (permalink)  
Old August 29th, 2012, 04:30 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am not sure I get this. Can you describe the use case? Why does this have to be so dynamic? I am not saying you don't need this, but you may be making this more complicated that needed.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #17 (permalink)  
Old August 29th, 2012, 04:47 AM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 29
Thanks: 11
Thanked 0 Times in 0 Posts
Default

for example,

using values to change the contents of gridview. i can do it without the help of datasource control

Code:
If Province_Ddl.SelectedValue = "Province1" Then
                Dim Province1Municipality = From city In myEntities.CityTbls
                                        Where city.Province = "Province1"
                                        Order By city.City
                                        Select city.City

                cityGridView.DataSource = Province1Municipality
                cityGridView.DataBind()

ElseIf Province_Ddl.SelectedValue = "Province2" Then
                Dim Province2Municipality = From city In myEntities.CityTbls
                                        Where city.Province = "Province2"
                                        Order By city.City
                                        Select city.City

                cityGridView.DataSource = Province2Municipality
                cityGridView.DataBind()

ElseIf Province_Ddl.SelectedValue = "Province3" Then
                Dim Province3Municipality = From city In myEntities.CityTbls
                                        Where city.Province = "Province3"
                                        Order By city.City
                                        Select city.City

                cityGridView.DataSource = Province3Municipality
                cityGridView.DataBind()

.
.
.
.
.
.
End If
by the way, our country has more than 75 provinces so i handcoded and copy-pasted them one by one.
  #18 (permalink)  
Old August 29th, 2012, 05:26 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
by the way, our country has more than 75 provinces so i handcoded and copy-pasted them one by one.
Really? Wow! What a nightmare that must be if you ever want to change something.

What about this:

Code:
Dim ProvinceMunicipalities = From city In myEntities.CityTbls
                                        Where city.Province = Province_Ddl.SelectedValue 
                                        Order By city.City
                                        Select city.City

                cityGridView.DataSource = ProvinceMunicipalities
                cityGridView.DataBind()
Not it works for all 75 of them, regardless of what you choose in the DDL.

To make this even easier, set up the data source for the GridView to use the SelectedValue of the DropDownList. This way, you can accomplsih the exact same thing without manual coding and just a few server controls.

You find an example that demonstrates exactly this (using Genres and Reviews) on page 446 and further in the section "Filtering Data".

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
rmanapul (August 29th, 2012)
  #19 (permalink)  
Old August 29th, 2012, 07:27 PM
Authorized User
Points: 109, Level: 2
Points: 109, Level: 2 Points: 109, Level: 2 Points: 109, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 29
Thanks: 11
Thanked 0 Times in 0 Posts
Default

wow thanks. i didn't know that controls can also be called in LINQ queries lol. im going to try that :)

Last edited by rmanapul; August 29th, 2012 at 10:00 PM..




Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net 2008 Print DataGridView (Text Wrap top header column and lock in width) remya1000 Visual Studio 2008 1 February 14th, 2012 12:56 AM
Export Column Header to Text File in SSIS lavisualstudio BOOK: Professional Microsoft SQL Server 2008 Integration Services ISBN: 978-0-470-24795-2 0 March 13th, 2010 09:55 PM
Runtime Column Header Text vinod_yadav1919 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 November 29th, 2008 01:53 AM
Changing the "From" header when sending email rinventive BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 May 23rd, 2006 03:56 PM
changing image/logo in report header h_haviv Crystal Reports 1 February 27th, 2005 07:59 PM





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