Solved

Passing Value

Posted on 2008-11-14
6
233 Views
Last Modified: 2013-12-17
I have created an web form in asp.net/c#.  When a user types something in a textbox and presses a button, the gridview shows the matching records.  That works just fine.

Now the problem that I am having is that when I move the textbox and button to the master page, I am experiencing some issues.  The issues I am experiencing are:
1.  The GridView's Stored procedure can't find the new control.  
2.  When the page opens, that has the search results,  the results of the text box are lost.

This should happen- a user types  in the textbox and presses submit, the new page opens (in the same window) and shows matching records. I am a beginner to asp.net/c#.  If someone could let me know how to do this step by step, that would be appreciated.  Thanks!
0
Comment
Question by:jjrr007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22966008
jjrr007,
Have you tried the last bits I posted in your other thread?
0
 
LVL 1

Author Comment

by:jjrr007
ID: 22966176
Thanks. I have just tried that.  Feel free to post here as well.  
0
 
LVL 3

Expert Comment

by:Rupesh P
ID: 22966194
Hi,
You have to get the control's value from the master page. Now your gridview control is in the content page and textbox and button are in the master page rt?

You have to pick the value from the master page itself.  To do this, this link will help you

http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:jjrr007
ID: 22968160
Thanks for your time.  This got me closer, but I couldn't get to work.

Using the link (http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx), the text box was found, helped, but I can get the value just yet.  When I used the code listed in the snippet, I see the words, "TextBox found!".  However, I can't have the value sent  to the GridView's query.  How do I do that?  That is really what I am look for.

Thanks again for the start.  
    protected void Page_Load(object sender, EventArgs e)
    {
          SqlDataSource1.SelectParameters.Add("ProductID", "");
        ContentPlaceHolder mpContentPlaceHolder;
        TextBox mpTextBox;
        mpContentPlaceHolder =
          (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder2");
        if (mpContentPlaceHolder != null)
        {
            mpTextBox =
                (TextBox)mpContentPlaceHolder.FindControl("TextBox2");
            if (mpTextBox != null)
            {
                mpTextBox.Text = "TextBox found!";
            }
        }

Open in new window

0
 
LVL 1

Accepted Solution

by:
urvinayan earned 500 total points
ID: 22984486
Hope the attached snippet helps

protected void Page_Load(object sender, EventArgs e)
    {
                  ContentPlaceHolder mpContentPlaceHolder;
        TextBox mpTextBox;
        mpContentPlaceHolder =
          (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder2");
        if (mpContentPlaceHolder != null)
        {
            mpTextBox =
                (TextBox)mpContentPlaceHolder.FindControl("TextBox2");
            if (mpTextBox != null)
            {
                            SqlDataSource1.SelectParameters.Add("ProductID", mpTextBox.Text);
      
            }
        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:jjrr007
ID: 31517037
Thanks. That worked
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question