|
Convert.ToDateTime uses the current culture. If you want to do culture specific stuff then u wud have to use DateTime.Parse passing it the culture.
|
|
|
|
|
is their anything i can to calculate difrence only hour, eg:
1. 60 hours
2. Not 2 Days and 12 hours
Sarfarj Ahmed
|
|
|
|
|
Timespan's TotalHours property does give you the total difference of hours ?
|
|
|
|
|
I have some files saved in a folder that I need to insert into a 2000 server. Can someone please help me with code for 2003.
I can't use the HtmlInputFile control
|
|
|
|
|
Anita_Kamat_inds wrote: I can't use the HtmlInputFile control
There is no other possibilities. ASP.NET can't read the folder and put files to DB.
|
|
|
|
|
well I used this and it works.
string sFilePath = @"C:\FF73JJ0000.tif";
byte[] bFile = new byte[fs.Length];
fs.Read(bFile, 0, bFile.Length);
SqlConnection connection = new SqlConnection(connectionString);
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into tblViewContracts "
+ "(ViewImage) values (@pic)", connection);
cmd.Parameters.Add ("@pic", bFile);
this kinds of works.
|
|
|
|
|
Yeah. So the folder will be on server?
|
|
|
|
|
|
Ok. I was thinking the folder is on client. BTW, what is the issue you are facing? You said the code provided is working.
|
|
|
|
|
yeah, at that time I needed help. I got it now. thanks man for atleast responding. if you don't mind can you tell me if a asp.net application application is accessing file on a server, is there a particular user that needs access too the server.
|
|
|
|
|
Anita_Kamat_inds wrote: is there a particular user that needs access too the server.
Usually ASP.NET user account will have read/write access in the website area. If not, it can be granted from the Properties window of that directory. Code accessing C:\SomeFolder may fail as ASP.NET will not have access to directories outside website area.
|
|
|
|
|
Hello Everybody
I want to compare date and time from two diffrent object
Example:
lblSystemDateTime = 10/02/2009 03:37:25
lblSelctedDateTime = 10/02/2009 14:30:00
I want to check wheather SelectedDateTime is 12 hours more than SystemDateTime
How can I check it.
Thanks
Sarfaraj
Sarfarj Ahmed
|
|
|
|
|
|
Actualy I want to calculate wheather customer date and time (input from customer) is 8 hours more than system date and time or not.
Anyway, Thank you very much for replying
Sarfarj Ahmed
|
|
|
|
|
DateTime Dt= DateTime.Parse("10/02/2009 03:37:25");
DateTime Dt2 = DateTime.Parse("10/02/2009 14:30:00");
TimeSpan t = Dt.Subtract(Dt2);
MessageBox.Show(t.TotalHours.ToString());
Now From Time Span you can get the time Difference
|
|
|
|
|
Dear Abhijit Jana
Thanks you very much.
You are a STAR
Thanks
Sarfaraj
Sarfarj Ahmed
|
|
|
|
|
It looks like the date OP is talking about is in dd/mm/yyyy format. If yes, your code will fail. It will take 02 as date and 10 as month. You need to use DateTime.ParseExact with an invariant culture and required format.
|
|
|
|
|
Hi all, somebody knows how create a array multi-dimensional with session variables.
I have it:
Session("Preguntas") = LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))
where it session is a table and I want to add the result of client into other session array but with 2 columns, something similar to
Session("ArrayRespuestas")(Session("i"), 1) = "1" .
I use session variable because when the user make click into button I receive a postback and lost my original select (LPH.ObtenerTest(Session("Articulo"), Session("Nivel"))) that is a procedure that return a select random with 2 parameters.
If I use
If Not Me.Page.IsPostBack Then and put my select into later (the second page_load) doesn't load my select and when I call to
Preguntas.Rows(i)("Respuesta1") I received a error where told me that I must first create a object.
Thanks for all.
|
|
|
|
|
The below code allows a multi-dimensional array to be stored in the session state. See if you can adapt this to fit your use. Good luck.
private void StoreToSession()
{
string[,]initialArray={"A","B"};
Session["sessionvalue"]=initialArray;
}
private void ReteriveFromSession()
{
string[,]resultantArray=(string[,])Session["sessionvalue"];
TextBox1.Text=resultantArray[0,0].ToString();
TextBox2.Text=resultantArray[0,1].ToString();
}
Ranjit Viswakumar
Professional Services Specialist
http://hostmysite.com/?utm_source=bb
|
|
|
|
|
Doesn't work because the postback empty my array when I push btton.
I have when load the first ask (is a test of 25 ask):
Public Ar1(25, 1) As Integer
Procedure of load ask
Ar1(Session("i"), 0) = Session("Preguntas").Rows(Session("i"))("Id_Pregunta")
Session("ArrayRespuestas") = Ar1
later when button_onclick:
Dim respuesta As Integer
If RadioButton1.Checked = True Then respuesta = 1
If RadioButton2.Checked = True Then respuesta = 2
If RadioButton3.Checked = True Then respuesta = 3
If RadioButton4.Checked = True Then respuesta = 4
If RadioButton5.Checked = True Then respuesta = 5
Ar1(Session("i"), 1) = respuesta
Session("ArrayRespuestas") = Ar1
Session("i") = Session("i") + 1
This work without errors, but when I try to recovery the datas of array I only get the value present Ar1(Session("i"), 1) but I lost the value Ar1(Session("i"), 0) because was added before of push button and later the postback empty my array.
Good, realty is when I put Session("ArrayRespuestas") = Ar1 is when I clear my session array.
I believe that the solve is to search like get not postback when click button.
I accept advisers boys
|
|
|
|
|
Solved
I put into page_load
If Not Me.Page.IsPostBack Then
Session("i") = 0
Dim Ar1(25, 1) As Integer
Session("ArrayRespuestas") = Ar1
End If
Then only I define the array a time
Thanks for your help
|
|
|
|
|
Hi,
my page postbacks many times and this button click occurs in between postbacks(one postback occurs due to button click).
when a particular button is clicked for the first time, a snippet will be executed and for other clicks of same button 'this' snippet should not be executed but some other code should be executed and for all clicks(including first click) it should remember(append the values to gridview) the previous values selected.
how can i achieve this senerio. IsPostBack is not applicable. Is there anyway to check clicks and save values in gridview (gridview is not in stored in DB)..
hope i am clear.. any doubts on my question are welcome....
Thanks in advance
|
|
|
|
|
If I understand your question correctly then I believe that a Session variable can help you.
You page should have at least two event handlers, one for Page_Load and one for your button OnClick event. Page_Load always executes first. When the page first loads it goes through Page_Load with IsPostBack == false and When you click the button it first calls Page_Load with IsPostBack == true, then it executes your Button_Click event where you should have the code snippet that you only want to execute one time.
Let's say here's your button click event handler:
public void MyButton_OnClick(object sender, EventArgs args)
{
if (Session("MyButton_Handled") == null)
{
// Your one-time code snippet goes here
// Set the session varaible
Session("MyButton_Handled") = true;
}
}
First time through the session variable will be undefined, which should return null. After you execute the code then the variable is defined and the one-time code gets skipped.
Ray Wampler
www.RayWampler.com
|
|
|
|
|
hi,
thanks a lot for your reply,
this is what i wanted, but i need the 'dt' value outside the if(session...) statement.As this is giving me "the name 'dt' doesnot exist in the current context" error. And if i create 'dt' outside this session statement, dt is initializing for every postback...
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox box1 = (CheckBox)row.FindControl("CheckBox1");
if (box1.Checked)
{
if (Session["MyButton_Handled"] == null)
{
DataTable dt = new DataTable();
dt.Columns.Add("Items");
dt.Columns.Add("Price");
Session["MyButton_Handled"] = true;
}
DataTable dt = (DataTable)Session["tablevalues"];
DataRow dr = dt.NewRow();
string name1 = row.Cells[2].Text;
double cost1 = Convert.ToDouble(row.Cells[3].Text);
dr["Items"] = name1;
dr["Price"] = cost1;
dt.Rows.Add(dr);
GridView2.DataSource = dt;
GridView2.DataBind();
Session["tablevalues"] = dt;
cost = cost + cost1;
Label12.Visible = true;
Label12.Text = "Total Price " + cost ;
}
thanks,
|
|
|
|
|
Now that I see your code I think that I can suggest something that will work. You're already storing the data table in session, so you don't need an additional session variable your code can check for the existence of the data table in session.
If I understand the issue correctly then what you want is the first time through to create the table and store it in session, and each subsequent time you want to add a new row to the existing table.
First you create a helper function that returns a data table. This is where you check the session:
private DataTable ItemTable()
{
if (Session["tablevalues"] == null)
{
DataTable dt = new DataTable();
dt.Columns.Add("Items");
dt.Columns.Add("Price");
Session["tablevalues"] = dt;
}
return dt;
}
The above code will create the data table in session if it does not exist and then return it. It it already exists then it returns what's there.
You now change your button handler as follows:
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox box1 = (CheckBox)row.FindControl("CheckBox1");
if (box1.Checked)
{
DataTable dt = ItemTable();
DataRow dr = dt.NewRow();
string name1 = row.Cells[2].Text;
double cost1 = Convert.ToDouble(row.Cells[3].Text);
dr["Items"] = name1;
dr["Price"] = cost1;
dt.Rows.Add(dr);
GridView2.DataSource = dt;
GridView2.DataBind();
cost = cost + cost1;
Label12.Visible = true;
Label12.Text = "Total Price " + cost ;
Session["tablevalues"] = dt;
}
The line of code, DataTable dt = ItemTable(), is going to get either a new table or table with the rows you added. You then add your new row, update the grid, and store the table in session.
I hope that's what you were looking for...
Ray Wampler
http://wwww.RayWampler.com
|
|
|
|