Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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
 
Old May 18th, 2005, 09:28 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Master-Details

Dear All,
i am trying to display master details in a single page.
i have used a datalist and a datagrid in my page.
datagrid has only "employee id" and a hyperlink "details".
on clicking details hyperlink, it shud display the rest info of employee in d datalist.

 the code is :

public class MasterDetails : System.Web.UI.Page
{
    protected System.Web.UI.WebControls.Label Label1;

    string sDetails="";
    protected System.Web.UI.WebControls.DataList dlistemp;
    protected System.Web.UI.WebControls.DataGrid datagrid;
    string intID="";

private void Page_Load(object sender, System.EventArgs e)
{
    if(this.IsPostBack ==false)
    {
       string strconn="Data Source=sapnew; Initial Catalog=master; Integrated Security=SSPI";
       SqlConnection myconn=new SqlConnection(strconn );
       string mysql="select * from employee";
       SqlDataAdapter ademp=new SqlDataAdapter(mysql, myconn);
       DataSet ds=new DataSet();
       ademp.Fill(ds, "employee");
       datagrid.DataSource =ds.Tables["employee"].DefaultView;
       datagrid.DataBind();

    } //if

      sDetails =Request.QueryString("empno");
      intID=Request.QueryString("id");


    if (sDetails=="details")
        {
        dlistemp.Visible=true;
        doShowDetails();
    }



}

private void doShowDetails()
{
    string strconn="Data Source=sapnew; Initial Catalog=master; Integrated Security=SSPI";
        string mysql="select * from employee where empno=" ;//+ intID;
    SqlConnection myconn=new SqlConnection(strconn);
    DataSet ds= new DataSet();
    SqlDataAdapter ademp=new SqlDataAdapter(mysql, myconn);
    ademp.Fill(ds, "employee");
    dlistemp.DataSource =ds.Tables["employee"].DefaultView;
    dlistemp.DataBind();
}



and am getting the error at d places highlighted in red.
actually am not sure how to do the coding for the "click on hyperlink" and how to display d data in the datalist after that.

can anyone plz help me out.

Thanks & Regards,
Muskaan.


 
Old May 18th, 2005, 09:38 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You've started with the right idea. I think you should change the link column in the datagrid to be a linkbutton column instead of a regular hyperlink column. Then you can take advantage of the power of postbacks. On the ItemCommand postback handler for the datagrid, you can call the code that populates the datalist for user details.

Regarding the code you have there, the SQL query in the doShowDetails() method is missing a value so that is probably what's breaking.

-Peter
 
Old May 19th, 2005, 04:45 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx Peter...
but cud you plz tell me where in d sql query there is a missing value?
and did u mean templated coloum or button column.
i didnt actually get it.

Regards,
Muskaan.

 
Old May 19th, 2005, 05:48 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Code:
 string mysql="select * from employee where empno=" ;//+ intID;
--------------------------------------------------^
empno=?????

-Peter
 
Old May 19th, 2005, 05:55 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

also cud u tell me templated column or button colum?

regds,
muskaan

 
Old May 19th, 2005, 06:02 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What are you asking about the columns? Which to use? That is up to you depending on what you would like to achieve.

-Peter
 
Old May 19th, 2005, 06:09 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okie....thanx anyways.

regards,
muskaan.

 
Old May 24th, 2005, 07:16 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am trying to display master details in a single page.
i have used a datalist and a datagrid in my page.
datagrid has only "employee id" and a hyperlink "details".
on clicking details hyperlink, it shud display the rest info of employee in d datalist in the same page.

now i am not getting how do i show the details in d datalist after clicking on hyperlink. how to do coding for that.

Can anyone help me out.

Thanks & Regards,
Muskaan.

i have mentioned the code above.



 
Old May 24th, 2005, 09:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The hyperlink on each column will be a linkbutton. This linkbutton will fire the grid's ItemCommand event. You need to call the showdetails method in a handler for this event.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
view details radheshsharma1032 .NET Framework 2.0 0 January 12th, 2008 10:06 AM
DataGridView Master/Details (Windows Forms) dvarrin C# 0 August 24th, 2006 07:08 AM
Details Height Paula222 Access VBA 1 April 11th, 2006 11:27 AM
Problem Details 3Moose BOOK: ASP.NET Website Programming Problem-Design-Solution 1 February 16th, 2005 10:42 AM
Help With Master Details Code In PHP Book placebo Wrox Book Feedback 1 November 21st, 2003 04:17 AM





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