|
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.
|
|
|
|
|
Actually, the dynamic control can persist data in the ViewState as the static control does. The important thing when working with the dynamic control is that you need to choose the right event to readd the dynamic controls. If this happens after the ViewState is loaded, then it will loose its ViewState data. For more information, you should read about the control life cycle in MSDN.
|
|
|
|
|
if you want to see the selected value each time, it is easy...
give it an ID, say idListBox.
while creating it, get the value from form variables to determine the selected value:
...
selVal = request.forms("idListBox")
loop
create a list item
if value of the item = selVal then add "selected" to the item
add item
end loop
...
That's it...
HainKurt
|
|
|
|
|
hi all
i have a string in dd/mm/yyyy (e.g 26/06/2006) i wants to insert in database as datetime format. the data type in database is DataTime.
pls send the syntex.
thankX
Regards,
Srinandan Mall
|
|
|
|
|
First parse the string into a DateTime value:
DateTime theDate = DateTime.ParseExact(theString, "dd/MM/yyyy", CultureInfo.InvariantCulture);
Then you can use the DateTime value in the call to the database.
---
b { font-weight: normal; }
|
|
|
|
|
Hi All,
when i want to create ASP.NET Web service i get this error
"Visual Studio not identify the version of ASP.NET on the Web server.The Web server reported the
following error when attempting to create or open the Web project located at the following
URL:'httpL//localhost/WebService1'.HTTP/1.1 401 Access Denied'.
Do you want to continue?
Yes No Help
if i click yes then i get one window Web Access Failed with three options
Retry using a different file share path
Location
Try to open the project with FrontPage server Extensions
Work offline
but in the end i cant created.
How to solve this problem?
Thanks
whitesky
|
|
|
|
|
Hi all,
I would like to create an online stock exchange trading software in ASP.Net, c# and sql server 2000 for a consultant company to display pricing list. I would like to know how can i get the online pricing list of NSE [National Stock Exchange], BSE [Bombay Stock Exchange] and Commodities Exchange.
Thanks
Naresh Kumar
|
|
|
|
|
The same i m looking for. If u get any help plz let me know the same. For more information u can add catchme_matrix@yahoo.com for yahoo messanger. Thanks
|
|
|
|
|
I want to use dropdown list in the datagrid pls tell me how to do this.
|
|
|
|
|