473,789 Members | 2,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView SelectParameter s

I am using a GridView with 3 SelectParameter s 2 of which are
ControlParamete rs, but the third of my SelectParameter values is derived
through my code rather than a QueryString, Control etc, so I need to add
my select parameters programmaticall y.

Here are my 2 ControlParamete rs are they were originally :

<SelectParamete rs>
<asp:ControlPar ameter Name="Month"
ControlID="ddlM onth" PropertyName="S electedValue" />
<asp:ControlPar ameter Name="Year" ControlID="ddlY ear"
PropertyName="S electedValue" />
</SelectParameter s>

And here are all 3 of my parameters declared within my Page_Load instead
:

SqlDataSource1. SelectParameter s.Add("UserKey" , TypeCode.Int32,
UserKey.ToStrin g());
SqlDataSource1. SelectParameter s.Add("Month", TypeCode.String ,
ddlMonth.Select edValue);
SqlDataSource1. SelectParameter s.Add("Year", TypeCode.String ,
ddlYear.Selecte dValue);
Is this the right way to do this programmaticall y?


*** Sent via Developersdex http://www.developersdex.com ***
May 30 '06 #1
1 6313
You don't need to manually add the ones that you've already done declaratively
(that's the point of the declarative model). For the 3rd parameter that you
must add dynamically, you can do it either in Page_Load or you can do it
in one of the Data Source Control's pre-processing events, like Selecting,
Updating, Inserting or Deleting.

-Brock
http://staff.develop.com/ballen

I am using a GridView with 3 SelectParameter s 2 of which are
ControlParamete rs, but the third of my SelectParameter values is
derived through my code rather than a QueryString, Control etc, so I
need to add my select parameters programmaticall y.

Here are my 2 ControlParamete rs are they were originally :

<SelectParamete rs>
<asp:ControlPar ameter Name="Month"
ControlID="ddlM onth" PropertyName="S electedValue" />
<asp:ControlPar ameter Name="Year"
ControlID="ddlY ear"
PropertyName="S electedValue" />
</SelectParameter s>
And here are all 3 of my parameters declared within my Page_Load
instead :

SqlDataSource1. SelectParameter s.Add("UserKey" , TypeCode.Int32,
UserKey.ToStrin g());
SqlDataSource1. SelectParameter s.Add("Month", TypeCode.String ,
ddlMonth.Select edValue);
SqlDataSource1. SelectParameter s.Add("Year", TypeCode.String ,
ddlYear.Selecte dValue);
Is this the right way to do this programmaticall y?

*** Sent via Developersdex http://www.developersdex.com ***

Jun 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8317
by: Mark Richards | last post by:
I posted this earlier, and got no response. Basically I need to be able to grab a value from one of the fields in a gridView to populate a dropdown in another column of the gridview: I have a gridView that has 2 templated columns that contain drop-down lists. The first drop down list uses a value off of a formview on the same page for filtering. The 2nd drop-down is supposed to use the value off the first drop-down for it's...
0
1497
by: Eiriken | last post by:
Hello everyone, I am using ASP.NET 2 and trying to bind a objectdatasource to a gridview. By doing this the most common way by adding an objectdatasource to the page and by using the wizard to connect to my business logic everything works fine. The problem is that I find this quite limited and I need to do some custom work with the parameters, so I am trying to code everything by hand in the code behind. >From a security perspective,...
6
8274
by: Dabbler | last post by:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to an SqlDataSource, then have a value from a boundfield in the row be passed as the keyfield for select where clause. Im trying to load the ddl with a list of dates from another table keyed on GridView row field that only apply to this row. Any suggestions would be appreciated.
0
1565
by: Frank | last post by:
Hello All, I am working with VS.NET 2005 and I have an editable GridView whose HTML markup is shown below. In short, when the user clicks on the Edit button, one of the textboxes is replaced with a DropDownList that displays account numbers in a list. If the user selects an account from the DropDownList that already exists in the list, I wish to hide the 'Update' button or column, along with displaying a warning message. I try to do...
0
1362
by: Frank | last post by:
Hello All, I am working with VS.NET 2005 and I have an editable GridView whose HTML markup is shown below. In short, when the user clicks on the Edit button, one of the textboxes is replaced with a DropDownList that displays account numbers in a list. If the user selects an account from the DropDownList that already exists in the list, I wish to hide the 'Update' button or column, along with displaying a warning message. I try to do...
1
541
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
3
1730
by: Richard Coltrane | last post by:
Hello Im reading this article about the Gridview: http://msdn.microsoft.com/msdnmag/issues/04/08/GridView/ Whilst I realise that im not forced to use their methods I do find it confusing that the article states that the code below is an example of the "recommended data binding approach in ASP 2.0". Why is placing DAL level code and connection strings on every page that uses
4
4190
by: chris | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
4
3487
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
4
8762
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click ‘Update’, the page returns to its original state (prior to clicking Edit) and no updates occur in the DB. What am I missing? I included the html code below. -- Thank-you, Barbara Alderton <body>
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.