 |
| 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
|
|
|
|

May 18th, 2005, 09:28 AM
|
|
Authorized User
|
|
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 18th, 2005, 09:38 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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
|
|

May 19th, 2005, 04:45 AM
|
|
Authorized User
|
|
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 19th, 2005, 05:48 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Code:
string mysql="select * from employee where empno=" ;//+ intID;
--------------------------------------------------^
empno=?????
- Peter
|
|

May 19th, 2005, 05:55 AM
|
|
Authorized User
|
|
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
also cud u tell me templated column or button colum?
regds,
muskaan
|
|

May 19th, 2005, 06:02 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What are you asking about the columns? Which to use? That is up to you depending on what you would like to achieve.
- Peter
|
|

May 19th, 2005, 06:09 AM
|
|
Authorized User
|
|
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
okie....thanx anyways.
regards,
muskaan.
|
|

May 24th, 2005, 07:16 AM
|
|
Authorized User
|
|
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 24th, 2005, 09:32 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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
|
|
 |