Get Selected Value for SqlDataSource Select Parameter located in Content Page from ListBox located in Master Page

i wanna Get Selected Value for SqlDataSource's Select Parameter located in Content Page from ListBox located in Master Page ? So how can i do that ?

 

Thanks in Advance..


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/6/2007 1:52:17 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

12 Replies
1130 Views

Similar Articles

[PageSpeed] 58

Write a public property in the MasterPage that returns the ListBox text/value, so that you can call it in your contentpages.

public partial class MasterPage1 : System.Web.UI.MasterPage
{
    public string ListBoxValue {
        get { return ListBox1.SelectedItem.Value; }
    }

    protected void Page_Load ( object sender, EventArgs e) { .... }
}

In you ContentPages, you can access it, by  calling ListBoxValue property

Thanks

-Mark post(s) as "Answer" that helped you


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
10/7/2007 5:33:23 AM

wow that was really nice method like it :) thanks and i'll mark your answer as an answer like how you said you footer text :) thanks again by the way...

but i would like you to answer something for me again..if i want to pass this value to sqldatasource select paramater, how can i do that ? i mean for example how can i reach specific select parameters value and put a value in it. for example again :) : you gave me a method to get the value from selected index of ListBox control located in Master Page and i want to use this value for SqlDataSource (located in Content Page) Select parameters referring to a condition in where statements and in according to this statement there are some datas being called from database and binded to detailsview. and which event of sqldatasource i should use and put my code under... ?

Thanks in advance...


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/7/2007 8:31:48 AM

Depending on the event in which you want to bind the datasource, you can set the SqlParameters on the datasource. If you want to bind it in the Page_Load

protected void Page_Load (object sender, EventArgs e)
{
    // set the parameters
    SqlDataSource1.SelectParameters["parameter name"].DefaultValue = ListBoxValue; // ListBoxValue from MasterPage
    // bind to the detailsview
    DetailsView1.DataSource = SqlDataSource1;
    DetailsView1.DataBind();
}

Thanks

-Mark post(s) as "Answer" that helped you


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
10/7/2007 8:42:27 AM

and the last one is default value is static or dynamic ?


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/7/2007 11:00:40 AM

Its dynamic, have you had set its value through code.

Thanks


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
10/7/2007 11:52:34 AM

Thanks again. You saved me from really terrible issue..

Have a nice day...


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/7/2007 4:38:16 PM

well i encountered some problems on doing it. Sad

  1. It says me i have to declare the parameters when i put it under Page_Load event using your way mentioned above

and long story short :

All i want is that :

This is my SqlDataSource control located in Content Page and i've set it like that (i've put a picture to show my sqldatasource control Select statement stuffs)

and this is my content page screenshot :

and this is the error system gave me:

and what i want is to relate ListBox1.SelectedValue (located in Master Page) to SqlDataSource's KullaniciID parameter. How can i do that .. Please help me and the people who might encounter same problem in the future :)

Thanks in advance and i'll be waiting your answer as much as soon.


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/7/2007 5:21:33 PM

Add a parameter as described in the image.

Thanks


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
10/7/2007 8:10:01 PM

Ok. I'll try it again and thanks for giving answers to my all questions :) i am appreciated.

Have a nice day and by the way i'll write again if i encounter another problem :)


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/7/2007 10:43:32 PM

E-Screw,

Great answer and graphics! 

e_screw:

Add a parameter as described in the image.

Thanks

 


Peter Kellner
http://73rdstreet.com and blogging at
http://PeterKellner.net
MVP, ASP.NET
0
pkellner
10/7/2007 11:30:50 PM

Thank you P Kellner and Atarikg

 


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
10/8/2007 5:53:11 AM

Thank you very much. I've just tried your way and now it is working properly :) and the way you offered me in your first reply to show me how to reach listbox value from master page in content page is so perfect :) i hold it..

Have a nice day...


I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)]
0
atarikg
10/8/2007 9:26:31 AM
Reply:

Similar Artilces:

Access a DropDownList Selected value in a user control from a content page(nested master page)
 Hi All,I have a DropDownList box in a user control called DDLs.ascx. i have a content page called Sample.aspx which is based on a nested master page. the master pages are called parentMP.master and childMP.master. now i am calling the user control(DDLs.ascx) in the childMP.master like below<%@ Register TagPrefix="ddls" TagName="dropdownboxes" src="~/test/DDLs.ascx" %> now as i said there are 2 Dropdownlist boxes ( ddl1 and ddl2) in this user control.what i want is to access the selected value of these dropdownboxes in the content page and pass them t...

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

Is there a way to select a value on the master page Content 1 and have that var avalible on sub page content 2?
Is there a way to select a value on the master page Content 1 and have that var avalible on sub page content 2? I want the user to choose a student # on the master page in Content 1.  This function works. I then have sub pages that have different tables to fill out.  I want the user to choose a number and have that number appear in the content 2. Thanks for any suggestions:) Hi BatmanFan, Since you've closed this question, could you please share with us the solution? Thanks.David QianMicrosoft Online Community SupportPlease remember to mark the replies as answers if ...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

How do i get master page's Controls value into Content page!!!
  Hi to All,   I have a Master Page that Contains 4 dropdown lists and 2 Checkboxlists(that contains lot of check box list items) and one Search Button. now i want to search according to master page's controls parameters and display it on content page.now my problem is how do i get the master page's controls(dropdown lists,Checkboxlists)  values into content page. i did use properties for that in master page and calling these properties in  content page like this: Master.master:public string RegionState { get {if (Session["regionState"] == nu...

persist dropdown list selected value across content pages of master page
Hi All,  I have a dropdown control in the master page in my project. The content pages are dependent on the value selected in the dropdown control.The problem is if the dropdown is selected in one page do not retains it's value while navigating to other content pages I need to keep the selected value persistent across the content pages. Does somebody know how to accomplished this. Thanks in advance, Nitin Within the DropDownList.SelectedIndexChanged event, you could simply set a cookie or a Session variable to your SelectedValue. Then, within the DropDownList.DataBound event...

Displaying a gridview in a content page based on the selection made in the master page menu control
 Please help me out with this !!  I have a dynamic menu control in my master page .I want to display a gridview on the content page based on my selection made in the menu control which is on the master page   There are several ways that you can accomplish this. Which part of displaying the data on gridview do you need help with?You can use a datasource such as sqldatasource or accessdatasource, etc. to bind it and tie it based on the ID value of the drop down list.Or you can do everything on the code-behind and set the gridview to a datasource, then databind. See example he...

Adding dropdowns Programatically To content page in Master Page and retrieving selected value in code behind
HiI have a content page where i need to programatically two pull down. The first one is populated on the server side. The second one is populated on the client upon selecting a value in the first pull down. So far I got this working fine. Then as I do a post back I want to retrive the selected value of the second pulldown (the one populated in the client). Thing is I can find a reference to the control but it is returned empy. No data, no selected value.This page already works outside of master pages. And if I try it with textboxes I can retrieve changes done in the client.Thanks &...

Hook up to a control's event located on the Master Page from the Content Page PLEASE HELP
I have a master page with a button, and I what to hook the button click event on the content page I allready tried this example http://fredrik.nsquared2.com/viewpost.aspx?PostID=328&showfeedback=true but in vb it doesn't work. Thank you ALL. Master Page Code: Public Event OnbtnGrava_Click As EventHandler Protected Sub btnGrava_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGrava.Click RaiseEvent OnbtnGrava_Click(sender, e) End Sub Content Page code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim mpButton ...

Pass value from Child page to Parent page ( to locate sub controls of parent page )
Team, This is a question related parent and child webform or webpage. My utlimate aim is to pass or update a control of my parent page from child page. The Design   Parent Page --------------   Parent DataList 1       Child DataList 1          Textbox1 Textbox2 Textbox3 Textbox4       Child Datalist 2          Textbox1 Textbox2 Textbox3 Textbox4       Child Datalist 3     ...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

How to acess the master page control value in content page
i want to acess the control which is the part of master page. i want that contol`s  value on the content page.   Friend, try to implement the logic mentioned here http://forums.asp.net/t/1272824.aspx and this one http://wiki.lessthandot.com/index.php/ASP.NET:_Access_Master_Page_controls_from_the_Content_Page Good luck!Please Don't forget to click "Mark as Answer" on the post that helped you.This can be beneficial to other community members reading the thread. Hi, You can try to refer this article:  Passing Information Between Content and Master Pages&...

Value of the control at Master page is not being set from the content page
I am trying to set the value of the control at Master Page from the child page(content page) but the value of the control at master page is not changing.."Hope its your Solution so Mark it as Answer"Ahmad SheikhMicrosoft Valuable Geekhttp://sharpcontents.blogspot.com Here is a good tutorial on doing this from scott. http://www.odetocode.com/Articles/450.aspx here is the part you are looking for I think. Protected Sub Page_Load(ByVal sender As Object, _                     &...

Web resources about - Get Selected Value for SqlDataSource Select Parameter located in Content Page from ListBox located in Master Page - asp.net.navigation-controls

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Using The LINQDataSource
-*+There is a new datasource control available in Visual Studio that works in much the same way as the SQLDataSource and the ObjectDataSource. ...

Gabriel Mongeon
Archive - Gabriel Mongeon

moredotnet
M ore d otnet .NET Interview Questions, ASP.NET, C#, VB.NET, XML, SQL Check Out http://www.dotnetUncle.com √ .NET NOTES OOPS in .NET .NET ...

Architectural Overview of the Windows Presentation Foundation Beta 1 Release
Introduction Windows Presentation Foundation Beta 1 Windows Integration New Features WinFX SDK Exploring the New Features Introducing "Express" ...

About Mikesdotnetting
I started this site as somewhere to store answers to bits and pieces that I see asked frequently in the forums at www.asp.net . Rather than type ...

Using MiniProfiler with SqlDataSource ASP.NET WebForms Control
public class ProfiledSqlDataSource : SqlDataSource{ protected override DbProviderFactory GetDbProviderFactory() { // get the "base" DbProviderFactory ...

ASP.NET Pivot Table - RadPivotGrid for ASP.NET AJAX
... reports. RadPivotGrid allows easy customization of all data reports. Try now! Use any declarative data source control (AccessDataSource, SqlDataSource, ...

Sign on
Sign On • Join • Forums Home User Name * Password * Remember me next time ( I forgot my password ) SUBMIT YOUR WTF Content Random Article All ...

ComboBox Sample
ComboBox is an ASP.NET AJAX control that, like the AutoCompleteExtender , combines the flexibility of a TextBox with a list of options that users ...

Resources last updated: 1/6/2016 10:31:30 AM