|
|
You could buy third party controls from a company like Telerik or upgrade to .NET 2.0
|
|
|
|
|
I've read some previous posts but am a bit confused. (Imagine that...) I have a webpage in an asp.net application in which the user enters a part number in a textbox.
strPartNumberInputReference = txtPartNumberInput.Text;
What I want to do is make this a session variable so that other pages can access this number. Basically the second web page will load data based on that part number entered.
Where within the code do I do this? Do I just put it in the first page? Within which function? Can I just do Session ["ptNum"] = strPartNumberInputReference and use it in the other pages. (I assume not as this doesn't seem to be working.) If I do the session in a function, does it have to be a public function?
As always, big thanks.
|
|
|
|
|
You may need to check your IIS settings to make sure session variables are enabled. Also check for session pooling for sessions to persist throughout the webspace. I have to believe that it must be a global setting in IIS.
|
|
|
|
|
leckey wrote: If I do the session in a function, does it have to be a public function?
No, you can do it in any function you want, in any page you want.
When you retrieve your object from session, be sure to cast it, as it is returned back as object
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
-- modified at 9:04 Wednesday 28th June, 2006
|
|
|
|
|
Elina Blank wrote: be sure to cast it, as it is returned back as string
Could you give me an example of what you mean?
Thanks!
|
|
|
|
|
Sure.
Here you are:
MyObjectType myObj = (MyObjectType)Session[myObjSessionIndex]
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Okay, so something like this?
string strPartNum = (string)Session(what the heck would my index be? Don't I give it a name or something in parenthesis?)
Thanks again for your help!
|
|
|
|
|
your index is the name in of your variable.
Store object in session
Session[name] = object
Retrieve from session
object = Session[name].ToString()
name is any string variable
ex:
name= "myObjectSessionKey";
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Okay, I don't think I'm doing this right. In my first .aspx.cs page I declared:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
Session["ptNum"] = strPartNumberInputReference;<br />
if (Page.IsPostBack)<br />
{<br />
<br />
BindData();<br />
}<br />
}
In the second aspx.cs page I did:
Session["test"] = object;<br />
object = Session["test"].ToString();
But the compiler doesn't like object just hanging out like that. What am I missing?
|
|
|
|
|
leckey wrote: Session["test"] = object;
object = Session["test"].ToString();
What type is your object?
try
object = (myObjectType)Session["test"];
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
I placed the following in the second .aspx.cs page:
object = (string)Session["test"];
I get the error "identifier expected"
|
|
|
|
|
Can you send code snippet, please?
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
No problem! Here is page one aspx.cs:
protected string strPartNumberInputReference;<br />
.<br />
.<br />
.<br />
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
Session["ptNum"] = strPartNumberInputReference;<br />
if (Page.IsPostBack)<br />
{<br />
<br />
BindData();<br />
}<br />
}
Page 2 code behind:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
object = (string)Session["ptNum"];<br />
if (!Page.IsPostBack)<br />
{<br />
<br />
BindData2();<br />
test2 = txtTest.Text; <br />
}<br />
}
|
|
|
|
|
On which line the compiler complains?
Have you declared/initialized object variable?
But first check, that it is not a keyword?
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Now the session variable is giving me a different problem
Basically what I'm trying to do: On the first page user enters a partnumber and the datagrid populates based on that partnumber. User goes to second page, second page already recognizes part number and populates a new grid based on that partnumber.
The BindData function for the first page works fine:
private void BindData()<br />
{<br />
strPartNumberInputReference = txtPartNumberInput.Text;<br />
<br />
<br />
string SQLString = "SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID WHERE p.PartNumber = @PartID"; <br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", strPartNumberInputReference);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds);<br />
<br />
dgParts.DataSource = ds;<br />
dgParts.DataBind();<br />
<br />
<br />
}
Page Load where session variable is:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
Session["ptNum"] = strPartNumberInputReference;<br />
if (Page.IsPostBack)<br />
{<br />
<br />
BindData();<br />
}<br />
}
So on the second page I have:
public string test2;<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
test2 = (string)Session["ptNum"];<br />
if (!Page.IsPostBack)<br />
{<br />
<br />
BindData2();<br />
; <br />
}<br />
}<br />
<br />
private void BindData2()<br />
{ <br />
string SQLString = "SELECT w.weight, wt.Description AS wtDescription, p.PartNumber from weights w INNER JOIN weighttypes wt on wt.ID = w.weighttypeid INNER JOIN Parts p on w.PartID = p.ID WHERE p.PartNumber = @PartID";<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.Connection = new SqlConnection(strConnectSQL);<br />
cmd.CommandText = SQLString;<br />
cmd.Parameters.Add ("@PartID", test2);<br />
SqlDataAdapter adapter = new SqlDataAdapter(cmd);<br />
adapter.Fill(ds2); <br />
ds2.Tables[0].TableName = "Weights";<br />
dgWeights.DataSource = ds2;<br />
dgWeights.DataBind();<br />
<br />
}
But I'm getting the error:Prepared statement '(@PartID nvarchar(4000))SELECT w.weight, wt.Description AS wtDes' expects parameter @PartID, which was not supplied
I'm trying to pass the test2 as the parameter which should be the strInputNumberReference from page 1.
So I think I still have something incorrect.
Again, thank you SOOO much for helping me with this!
|
|
|
|
|
You are welcome.
Check with the debugger, where exactly you fall down.
Unfortunatelly, I have to do my staff now.
Can not figure out the problem straight.
Just one thing: shouldn't you specify command type? Text/SP
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
One more note
"object" is a keyword, if I remember it correctly
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Elina Blank wrote: When you retrieve your object from session, be sure to cast it, as it is returned back as string
Well, actually not a string, but an object.
---
b { font-weight: normal; }
|
|
|
|
|
You are right, thanks
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Hi all,
I'm trying to save changes made to a web parts page to the db, I can add the webparts programatically but they disappear on the first postback. I've read about extending the WebPartManager class to use the SetPersonalizationDirty() function, but as I'm still fairly new to using WebParts I'm not sure how to do this.
Basically what I would like to know is how to gain access to the class itself to write an override function, or whether or not I can put the function in the existing code.
Thanks in advance for any help or suggestions, Cheers.
A humble novice,
Lil Turtle
|
|
|
|
|
Hi there,
Because the SetPersionalizationDirty is defined as below:
protected void SetPersonalizationDirty () So you cannot override this method, what you may do is to inherit from this class, and define a new public method which in turn calls the protected method SetPersionalizationDirty. The sample code looks something like;
public class MyWebPartManager : WebPartManager
{
public void ExSetPersonalizationDirty()
{
SetPersonalizationDirty();
}
}
|
|
|
|
|
Thanks for the reply, and the info. I implemented the changes you suggested and the code runs wonderfully.
Thanks again.
A humble novice,
Lil Turtle
|
|
|
|
|
Hi all,
I need to create a Web Controls Table which 3 columns namely Date, From Time, To Time.I have a button on my Web Form(parent) form which I open dialog window which has calender control and time combo.When I select the date and from time and to time,I have to display all the 3 values in the table.
Can any one tell me how do I create this table with headings and how do I display all the values??
Also I do need multiple rows I mean I do have to insert min 2 records in this table.
Please help me with the code.
Thanks in advance.
|
|
|
|
|
I created a drop downlist dynamically and i am unable to capture its values i.e its view state.
I know that view state can't be retained for dynamically created controls .pls suggest a way out to retain the view state.
|
|
|
|