|
|
I am using Access database and I have a date field which is in format of DD/MM/YYYY. In my drop down list I have enabled items like 1 day, 2 day ,3days and etc. I would like to know how to convert the drop down list selection day and update the date of dB field?
E.g User select from drop down list :- 2 days
Current date is 03/05/2006
So the expected return date field in dB its 03/05/2006 + 2 days.
FYI, I am using VB code with ASPX using ASP 2.0 WEB MATRIX.
Please advise.Thanks
Jason
|
|
|
|
|
Use the DateAdd fucntion
newDate = DateAdd(DateInterval.Day, NumberOfDaysToAdd, currentDate)
cheers
Phil
|
|
|
|
|
Hi Phil,
My scenario is I have a data grid with the field Date set to Date/Time format.
I have created a drop down list outside and hardcode drop down list into the drop down e.g 1 day, 2 day,3day. I am not sure how I could grab the value of the selected drop down list item and update it in the Date field with its DD/MM/YYYY format.
The procedure you provided me could not hint me more to solving the problem.Sorry as I m still a beginner and am using ASPX but using VB.NET code.
Please advise or provide any suggestions to this.Thanks.
Jason
|
|
|
|
|
Still not quite sure what you're trying to do... update every row of the field date column?
cheers
P
|
|
|
|
|
While hard-coding the DropDownlist entries, i hope you have set both Text and Value properties. if not go to the properties window of the dropdown list and click on the columns property, which will pop up new window enabling you to enter Text and Value propeties for that ddlist. if you are binding the DD list in code behind code then follow as below
DropDownList1.Items.Insert(0,"1day");<br />
DropDownList1.Items[0].Text="1 day";<br />
DropDownList1.Items[0].Value="1";<br />
<br />
DropDownList1.Items.Insert(1,"2days");<br />
DropDownList1.Items[0].Text="2 days";<br />
DropDownList1.Items[0].Value="2";
go on filling the DropDownList1 as shown above.
string val = DropDownList1.SelectedValue.ToString();
will give the Selected value of the DropDownList1
now below code will change the value of the DataGrid1 Cell values for the entire date Column.
here it si assumed that Date column is the first column. if the Column position is n then replace Cell[0] with Cell[n-1]
for(int i=o;i<DatGrid1.Item.Count;i++)<br />
{<br />
DataGrid1.Item[i].Cells[0].Text = Convert.ToDateTime(DataGrid1.Item [i].Cells[0].Text.ToString().AddDays(Convert.ToDouble (DropDownList1.SelectedValue.ToString())).ToString("MM/dd/yyyy") ;<br />
}
Above Single line of code can replaced as given below
string DDval = DropDownList1.SelectedValue.ToString();<br />
for(int i=o;i<DatGrid1.Item.Count;i++)<br />
{<br />
DateTime CellVal = Convert.ToDateTime(DataGrid1.Items[i].Cells[0].Text.ToString());<br />
<br />
CellVal = CellVal.AddDay(DropDownList1.SelectedValue.ToString());<br />
<br />
DataGrid1.Item[i].Cells[0].Text = CellVal.ToString("MM/dd/yyyy"); <br />
<br />
}
once the values have been changed in the datagrid it is up to you to update the same to the database.
Cheer
Ramesh.Kanjinghat
|
|
|
|
|
in the above code the fopr loop is not printed prperly
for(int i=0;i<DataGrid1.Items.Count;i++)<br />
{<br />
DataGrid1.Item[i].Cells[0].Text = Convert.ToDateTime(DataGrid1.Item [i].Cells[0].Text.ToString().AddDays(Convert.ToDouble (DropDownList1.SelectedValue.ToString())).ToString("MM/dd/yyyy") ;<br />
<br />
}
and repeat the same for the next for loop
Ramesh.Kanjinghat
|
|
|
|
|
Hello all,
I have created an Activex control using VC++.Using the object tag ,i call its dll in asp.net page.
<object ID="AxPlayer"<br />
classid="clsid:AFB6AA3F-5D76-41E4-B6D9-6AD20026A988"<br />
codebase="http://localhost/ActiveX/AxPlayer.dll#Version=1,0,0,3"<br />
hspace=0<br />
vspace=0 ><br />
<br />
</object>
Since the Dll size is in Mbs ,it takes more time to download and showing white space in the Page while downloading.
I need to keep flash in the page showing the text "Activex control is Downloading".
1.how to do that??.
2.i need to play the flash only when the dll downloads.
please help me.
cheers
sangeet
-- modified at 5:23 Wednesday 3rd May, 2006
|
|
|
|
|
How about adding a table with a cell that has a background image with the text "ActiveX control is downloading".
Inside the cell you add your Flash object code.
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
thanks for ur reply
yes i can add a table with a cell.
But i need to make the table invisible after dll downloads.
so first i need to find whether dll is downloaded or not.
how do i find that..
cheers
sangeet
|
|
|
|
|
You can just set border="0" on the table which will keep the table invisible
<table border="0" width="100%">
<tr><td align="center" bgimage="downloading.jpg">
<object .... etc.
FLASH
</object>
<td>
</tr>
</table>
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Hi everybody.
I got the following Exception when i try to hide a column filled by a dataset:
Index was out of range. Must be a non-negative and less than the size of the collection. Parameter name : index
I dont understand why i got this error because when i try to get a data from this column with Gridview.Rows[myrow].cells[thecellofmycolumn].Text , I have no error.
Does anyone got an idea how to resolve it?
Thx
|
|
|
|
|
What's the code that gives the error? Where is it called from?
|
|
|
|
|
I do this in the Page_Load. here is the code:
Gridview.DataSource = MyDataSet;<br />
Gridview.Databind();<br />
Gridview.Columns[1].Visible = false;
When i try to get a value of this column i don t have any error. here is the code to get a value:
string value = Gridview.Rows[MyRow].Cells[1].Text;
-- modified at 7:32 Wednesday 3rd May, 2006
|
|
|
|
|
I have an asp.net Web App and I have a bunch of classes that hold the information from a page for example, I have a page form.aspx and it initialises a class info.class which holds all the information.
Now when I click a button on that page the class loosing all its values and the are set to null again. Does view state not save this class or is it just for front end things like textboxes,
If I can't do it with view state:
Should i store the class it in a DB
or session var
or in the cache????????
Thanks in advance
|
|
|
|
|
You can store it in viewstate, but you have to code it yourself:
Viewstate("MyClass") = myClassInstance
and to return it:
myClassInstance = ViewState("MyClass")
however, your class must be serializable to save correctly. If your class is very large, you may want to consider using session instead, as everything in viewstate will be sent over the wire to the client.
If you store it in cache, then the same data will be used for every user of the application.
|
|
|
|
|
Hello,
Hope you all will be fine,I want to send multiple values through "location.href" after getting these values from DropDownList in ASP.net using C#, How can i do that? the DropDownList is in HTML not <asp:dropdownlist>. The code is like that;
location.href='addsuccess.aspx?color='+<%=colordropdown%>.options[<%=colordropdown%>.selectedIndex].value
Moreover I am calling this on "onClick" Event of an Image.
Hope you will understand,
Regards,
AbuBakar
|
|
|
|
|
Would it not need to be something more like this:
location.href='addsuccess.aspx?color='+<%=colordropdown.options[colordropdown.selectedIndex].value%>
|
|
|
|
|
Yes paddyboyd you are right it is working quite well but in this way i can only pass one value like color but in real case i want to pass more than one value so how is it possible to pass more than one values in following string ???????
location.href='addsuccess.aspx?color='+<%=colordropdown.options[colordropdown.selectedIndex].value%>
Regards
|
|
|
|
|
Separeate the values using the & character, e.g. create an url in the format:
addsuccess.aspx?color=3&something=42
---
b { font-weight: normal; }
|
|
|
|
|
hi friends,
i need to use lucene - wildcard search, but i don't know how to do it, is anybody has done this here before, please give me the piece of codings.and also please tell me, how to search if my starting characters is in German Language like ä.
kpsetty
|
|
|
|
|
|
Hi,
If I want to save an uploaded file to subfolderX I can use this:
objFile.SaveAs(Server.MapPath("subfolderX\" & savedFilename))
OK, no problems. But now I want to check that subfolderX exists, and create it if it doesn't. So I do this:
If Not System.IO.Directory.Exists(Server.MapPath("subfolderX")) Then
System.IO.Directory.CreateDirectory(Server.MapPath("subfolderX"))
End If
OK, no problem. This works.. on my local machine. When I try it on my ISP's server I get an error: "Could not find a part of the path e:"
When I contacted them they suggested I try hard-coding the fully qualified network path instead:
If Not System.IO.Directory.Exists("\\iisX\domains\x\....\subfolderX") Then
System.IO.Directory.CreateDirectory("\\iisX\domains\x\...\subfolderX")
End If
This works - but why doesn't Server.MapPath, esp given that it DOES work for saving files??!! This doesn't make sense to me...
I don't want to use the hard-coded version if possible, as it doesn't lend itself well to the application's portability.
Any deas, anyone...?
thanks
Phil
|
|
|
|
|
Try printing out what path the Server.MapPath() method returns, and see if this helps.
The reason the createdirectory doesn't work seems to have to do with the fact that your application is hosted on a different machine internally in the hosting company, since you have to give them the full networkpath.
How about it if you try with the Tilde "~" character (implying the current application)?
Server.MapPath("~/subfolderX")
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Jakob Lund Krarup wrote: Try printing out what path the Server.MapPath() method returns
I have - it gives "e:\...." (etc)
Jakob Lund Krarup wrote: How about it if you try with the Tilde "~" character
Same as above.
Jakob Lund Krarup wrote: The reason the createdirectory doesn't work seems to have to do with the fact that your application is hosted on a different machine internally in the hosting company, since you have to give them the full networkpath.
Weel, yes... but why then does
objFile.SaveAs(Server.MapPath("subfolderX\" & savedFilename))
work fine but
System.IO.Directory.CreateDirectory(Server.MapPath("subfolderX"))
not? That's the really puzzling thing.
thanks
Phil
|
|
|
|