473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to transfer a dataset and a string from page to user control

Hi all
I have to transfer a dataset and a string from a webform to a user
control on the page without using viewstate or session or cookies .
properties method is not working properly. if anybody thinks that is
fine so plz describe me and send me any article or example for that.

How can i do that

Plz send any article if any body have regarding this
plz Also cc to Mu****@efextra.com
Thx in advance

Mukesh
Mu****@efextra.com
Jun 24 '06 #1
7 1461
In my understanding you have a custom control or user control that
you've placed in a webform. Now, in the webform you have a dataset or
any data that you want to give it back to the control for processing
it.

The best way to do this is to use properties in the control and assign
the dataset from the webform when ever you want to process it.

This is the straight forward way for this issue.

If you tried the same and got failed in any case, try post some code
with a breif explanation about how your're doing it.

Vadivel Kumar
http://www.vadivelk.net

Mukesh wrote:
Hi all
I have to transfer a dataset and a string from a webform to a user
control on the page without using viewstate or session or cookies .
properties method is not working properly. if anybody thinks that is
fine so plz describe me and send me any article or example for that.

How can i do that

Plz send any article if any body have regarding this
plz Also cc to Mu****@efextra.com
Thx in advance

Mukesh
Mu****@efextra.com


Jun 24 '06 #2
Vadivel Kumar wrote:
In my understanding you have a custom control or user control that
you've placed in a webform. Now, in the webform you have a dataset or
any data that you want to give it back to the control for processing
it.

The best way to do this is to use properties in the control and assign
the dataset from the webform when ever you want to process it. this is my example




This is the straight forward way for this issue.

If you tried the same and got failed in any case, try post some code
with a breif explanation about how your're doing it.

Vadivel Kumar
http://www.vadivelk.net

Mukesh wrote:
Hi all
I have to transfer a dataset and a string from a webform to a user
control on the page without using viewstate or session or cookies .
properties method is not working properly. if anybody thinks that is
fine so plz describe me and send me any article or example for that.

How can i do that

Plz send any article if any body have regarding this
plz Also cc to Mu****@efextra.com
Thx in advance

Mukesh
Mu****@efextra.com

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace property
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.UserControl Test1;
public DataSet ds = new DataSet();
public string qw;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string select ="select * from PropertyDisplay2";
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper cmd = db.GetSqlStringCommandWrapper(select);

db.LoadDataSet(cmd,ds,"Results");
qw="jnbdfgkdfjsgh";
Controls.test mk = new Controls.test();
// mk.Mystr="mukesh agarwal";


// Test1.FindControl("DataGrid1").DataBind();
// property.Controls.test mk = new property.Controls.test();
// mk.i=125;
//
// Label lblbvl= (Label)Test1.FindControl("Label1");
// lblbvl.Text= "rjhgkjfdhgkfdjg";
// mk.MyNumber= 321321;

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void dataView1_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
{

}
}
}

namespace property.Controls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for test.
/// </summary>
public class test : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label Label1;
string i;
public string Mystr
{
get
{
return i;
}
set
{
i = value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Label1.Text += Mystr;
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

Jun 24 '06 #3
Hi Mukesh,

Thank you for your post and sample code.

Normally you use ViewState to store simple property of the User Control,
for example:

public string Mystr
{
get { return ViewState["Mystr"] as string; }
set { ViewState["Mystr"] = value; }
}

And for the DataSet you need to pass to UserControl's DataGrid from the
WebForm, you can directly expose DataGrid's DataSource property:

public object DataSource
{
get { return DataGrid1.DataSource; }
set { DataGrid1.DataSource = value; }
}

Then you can set the DataSource of the UserControl in WebForm:

WebUserControl1 uc1 = FindControl("WebUserControl11") as
WebUserControl1;
uc1.DataSource = ds1;
uc1.DataBind();

You can do this in WebForm's Page_Load.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #4
HI Wang
I m using .net 1.1 and vs2003
pl z help me according to the environment.

Thx

Mukesh

Walter Wang [MSFT] wrote:
Hi Mukesh,

Thank you for your post and sample code.

Normally you use ViewState to store simple property of the User Control,
for example:

public string Mystr
{
get { return ViewState["Mystr"] as string; }
set { ViewState["Mystr"] = value; }
}

And for the DataSet you need to pass to UserControl's DataGrid from the
WebForm, you can directly expose DataGrid's DataSource property:

public object DataSource
{
get { return DataGrid1.DataSource; }
set { DataGrid1.DataSource = value; }
}

Then you can set the DataSource of the UserControl in WebForm:

WebUserControl1 uc1 = FindControl("WebUserControl11") as
WebUserControl1;
uc1.DataSource = ds1;
uc1.DataBind();

You can do this in WebForm's Page_Load.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '06 #5
Hi Mukesh,

Thank you for your update.

I'm not sure about your question on this. I think the code should work in
ASP.NET 1.1. Have you encountered some error when using the code? Please
feel free to post here if you need more help on this.

Have a nice day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '06 #6
Hello

Mr. Wang

Thanks for your great support

The code is working in asp .net 1.1 with C# after some changes
Thanks again for ur support

Mukesh Agarwal
New Delhi(India)
Walter Wang [MSFT] wrote:
Hi Mukesh,

Thank you for your update.

I'm not sure about your question on this. I think the code should work in
ASP.NET 1.1. Have you encountered some error when using the code? Please
feel free to post here if you need more help on this.

Have a nice day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 29 '06 #7
Hi Mukesh,

Appreciate your update and response. I am glad to hear that the problem has
been fixed. If you have any other questions or concerns, please do not
hesitate to contact us. It is always our pleasure to be of assistance.

Have a nice day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 29 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tom | last post by:
Hi I am trying to transfer to a different .ASPX page using Server.Transfer. However, I get the following error: "Error executing child request for .aspx." Anyone know why? Thanks for...
0
by: Moheb Missaghi | last post by:
Hi: I am trying to use the Transfer statement in an .aspx file to redirect and send Form and QueryString collections to a different page. A good example where this is needed is a checkout page...
5
by: Jason | last post by:
I am having problems understanding how to access a datasource only once, fill a single dataset, and then reference that dataset multiple times through different user controls(ascx) found on the...
1
by: yma | last post by:
Hi, I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by using ole DataAdapter, Connection and dataset controls. But I got "It is already opened exclusively by another...
5
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user...
2
by: Pete | last post by:
Hi all... I sincerly hope one of the MS guys can clear this up for me... First some background... Ok, I have a web site which is fully translatable into several languages. All the strings...
11
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it...
4
by: Brian | last post by:
Hi, I'm trying to make an online FTP utility in C# ASP.NET using MSINET.ocx (an active X control a.k.a. "Microsoft Internet Transfer Control") I've added the reference into my project and have...
3
by: Mukesh | last post by:
Hi all I have to transfer a dataset and a string from a webform to a user control on the page without using viewstate or session or cookies . properties method is not working properly. if...
0
by: daokfella | last post by:
I have a Login.aspx page that takes care of all my login procedures (validation, lockouts, password change requirements, password retrieval, etc.) It works like a charm. However, now I'd like a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.