[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

asp.net c# master page content manipulation

Hello Experts,
I have created a master page. and have 3 content holders in it with navigation menu on left hand side

now --> add new item --> a.aspx   b.aspx  c.aspx  page were created

now in aspx page directive i have added --> MasterPageFile="~/start.master
and removed all hml lines fom the page // i havnt used slect master page thing that time
well now my querry
My master page has content 1 has gridview
my master page content 2 Image
1) can I add asp:content now in aspx page or i need to create the page once again
2) how do i change querry string for content 1in different aspx pages and manipulate display of grid view
3) how do i change image (logo) in differnt aspx page that is content2

if source code example in c# is provided then it would be wonderful thing
any suggestions if i could do something in better way to be an expert or professionl??

thanks in Advance


0
dontnetsanjay
Asked:
dontnetsanjay
  • 4
  • 2
1 Solution
 
sabeeshCommented:
try like this
ContentPlaceHolder pl = (ContentPlaceHolder)Master.FindControl("contentpalaceholder1");
        GridView gv = (GridView)pl.FindControl("GridView1");
        gv.DataSource = "";
        gv.DataBind();

like wise you can set what ever you want .
0
 
dontnetsanjayAuthor Commented:
hello sabeesh
thanks

protected void Page_Load(object sender, EventArgs e)
    {
        ContentPlaceHolder pl = (ContentPlaceHolder)Master.FindControl("contentpalaceholder1");
        GridView gv = (GridView)pl.FindControl("GridView1");
        OleDbConnection dbcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=d:\\account\\register.mdb");
        dbcon.Open();
        OleDbCommand dbcom = new OleDbCommand("SELECT [email] FROM [emailbook]", dbcon);
        OleDbDataReader dbread = dbcom.ExecuteReader();
        gv.DataSource = dbread;
        gv.DataBind();
       
        dbread.Close();
        dbcon.Close();

    }

I get an error message ==>
" Object reference not set to an instance of an object. "

I dont have anything in aspx page  master page I have one gridview gridview1 in content place holder

Sanjay
0
 
dontnetsanjayAuthor Commented:
hello again

in my aspx (content page)

I have master page visible with content holder

what should bethe content task?
default master page content  or create custom content

i have gridview as default content in master Page GridView1
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
sabeeshCommented:
ContentPlaceHolder pl = (ContentPlaceHolder)Master.FindControl("contentpalaceholder1");
      //
      if(pl != null)
{
        GridView gv = (GridView)pl.FindControl("GridView1");
if(gv != null)
{
        OleDbConnection dbcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=d:\\account\\register.mdb");
        dbcon.Open();
        OleDbCommand dbcom = new OleDbCommand("SELECT [email] FROM [emailbook]", dbcon);
        OleDbDataReader dbread = dbcom.ExecuteReader();
        gv.DataSource = dbread;
        gv.DataBind();
       
        dbread.Close();
        dbcon.Close();
}
}
0
 
dontnetsanjayAuthor Commented:


no error now but nothing is displayed within the contentplaceholder1
0
 
dontnetsanjayAuthor Commented:
content that is pl condition is null its not doing rest of the thing??

any help here?

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now