|
Hi,
Use
string.Format("{o:dd/MM/yyyy}",yourdate);
check whether mm or MM
Thanks,
Sushant Duggal.
-- modified at 5:49 Thursday 29th June, 2006
|
|
|
|
|
I don't know how you can do date conversion in SQL, but you can use the following code to do this in page code:
foreach (DataGridItem item in dgrd.Items)
{
DateTime date = DateTime.Parse(item.Cells[1].Text);
item.Cells[1].Text = date.ToShortDateString();
}
This sould work, but if result is not in dd/mm/yyyy format then use the following:
foreach (DataGridItem item in dgrd.Items)
{
DateTime date = DateTime.Parse(item.Cells[1].Text);
string text = date.Day + "/" + date.Month + "/" +
date.Year;
item.Cells[1].Text = text;
}
Just make sure data type for the column in database is datetime. If it is not, use a try...catch loop when parsing string to prevent error.
Regards,
lordfkiller
|
|
|
|
|
Hello, where should I implement this? in the itemdatabound?
|
|
|
|
|
This is what I usually do:
The code should be executed after DataGrid is data bound(DataGrid.DataBind() is called). So that it can edit DataGrid items. In post backs, you don't need to data bind DataGrid, because it is already data bound (in load), but you may need to run converting code in post backs, too. To do so, data bind DataGrid in page_load (use if(!IsPostBack)). Place code for modifying DataGrid in a separate method and call it in page_load (outside if(!IsPostBack)).
If you are using ASP.NET 2, note that when you do data binding using a DataSource, you still need to call DataGrid.DataBind() in page_load. Because this method is called after page_load in page life cycle and you need to work on DataGrid in page_load, you must call it explicitly.
But using ItemDataBound, it is much better and easier:
protected void dgrdWebSites_ItemDataBound(object s, DataGridItemEventArgs e)
{
DateTime date = DateTime.Parse(e.Item.Cells[1].Text);
string text = date.Day + "/" + date.Month + "/" +
date.Year;
e.Item.Cells[1].Text = text;
}
Nothing more is needed!
Let me know if you need more explanation.
Best regards,
lordfkiller
|
|
|
|
|
Hi,
I need to drag the files from the folder in windows explorer and drop the files in the datagrid of asp.net 2.0 so that i need to get the file properties in the datagrid.
Thanks in advance
Phanindra...
|
|
|
|
|
?
Good luck.
|
|
|
|
|
If possible can i insert photo to microsoft acess while insert some record also?
If i can, what about when i retrive it to web page?
Thanks
................
|
|
|
|
|
Hi,
U may want to refer to this article
http://www.beansoftware.com/ASP.NET-Tutorials/Images-Database.aspx
|
|
|
|
|
1. How to add a checkbox in the header(next to ‘Select All’) of the datagrid control.
2. If I select the header checkbox then all the other checkboxes should be automatically checked.
3. After the above thing is achieved,if I uncheck any of the checkboxes ,the header checkbox must be unchecked automatically.
Please kindly help me in this issue
Thanks a lot
arun
|
|
|
|
|
This is the java script for select-all
/* Function for check all the check boxes in the Grid*/
function SelectAllCheckboxes(spanChk)
{
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i
|
|
|
|
|
hi Arun,
1.you need a Template Column for this . Add a template column to your datagrid.
put two checkboxes in the Header and ItemTemplate
column.
2.for the second query you can do it in two ways.
a.if you want to do it in the client side.......
you have to put your code in the onclick event handler of the header checkbox.put onclick="checkingboxes()"
here checkingboxes() is the client side Javascript function.
function checkingboxes()<br />
{<br />
dgChkItem.checked=true;
}
b. if you want to do it in the server side.....
make the AutoPostBack property of the header checkbox to true .
In the CheckedChanged event handler put code for checking the
ItemTemplate checkbox
in the dgChkHead_CheckedChanged(....) event put
e.Item.FindControl("dgChkItem").checked=true;
Tirthadip
Live life to the fullest
|
|
|
|
|
In ASP.NET 2.0 with C# I have a page with a formview in EditMode and in it 2 dropdownlist that one is a controll parameter to the other. One is Country and it is a parameter for the second. I can't make the second dropdownlist a bound field because if I do it when I change the country in the country dropdown list I get an error. How to deal with a situation like this? Can the second Dropdoenlist be bounded? with a Bound value?
ThankYou
Anat
|
|
|
|
|
hi
i hope u want the value from one dropdown to seconddropdown.i guess
if i m right then would u please tell me what error are u getting may be i help u.
thanx
aavesh
|
|
|
|
|
Dear Friends,
How can i use Excel File Complete functionality(Formula's)through ASP.NET 2005 (C#) Coding. (Not HTML Coding)
Please Help ME Dear Friends.................................
Haridas.R
harisofttech@hotmail.com
"Achievement is not a destination, its a journey "
|
|
|
|
|
Hello,
I am developing an online shopping website, i have finished it now I want to send values or parameters to 2CO for shopping can anyone tell me that how can i do that or send me any string or code to send values to 2CO ? i am using c# and asp.net.
Regards,
AbUbakar
|
|
|
|
|
I have an Interface say InterfaceA which has two method declarations
Method A & Method B
The above interface is implemented by Class X
Additionally Class X also has two more methods
Method C & Method D
If I instantiate an object of Class X,
I want only Method C and Method D to be exposed.
The Method A and Method B should not be exposed by default to the user unless he explicitly casts it..How do I design such an interface and how will the user do the 'casting' if required
If anybody knows how to do this..pls help
Dimple
|
|
|
|
|
public interface IInterfaceA
{
void MethodA();
void MethodB();
}
public class X : IInterfaceA
{
void IInterfaceA.MethodA() { }
void IInterfaceA.MethodB() { }
public void MethodC() { }
public void MethodD(){}
} Explicit Interface Implementation[^]
|
|
|
|
|
Hi,
Thanx for the info...But I was trying to implement this with VB.Net..Saw a few posts on the topic..Was wondering why this feature has been highlighted as an advantage point in C#...Can i not do the same in VB.Net?
Dimple
|
|
|
|
|
Could you just do this:
<br />
<br />
interface A<br />
{<br />
Method A<br />
Method B<br />
}<br />
interface B<br />
{<br />
Method C<br />
Method D<br />
}<br />
<br />
Class X: Interface A, Interface B<br />
{<br />
... etc.<br />
}<br />
<br />
And then have user only instantiate one of type a or type b.<br />
<br />
<br />
|
|
|
|
|
Hmm, I'm not a true VBer , but you might think of hidding the interface's methods in the implementation class with the low access level like private or protected :
Public Interface IInterfaceA
Sub MethodA()
Sub MethodB()
End Interface
Public Class X
Implements IInterfaceA
Private Sub MethodA() Implements IInterfaceA.MethodA
End Sub
Protected Sub MethodB() Implements IInterfaceA.MethodB
End Sub
Public Sub MethodC()
End Sub
Public Sub MethodD()
End Sub
End Class Btw, for this kind of question, you might want to ask in the VB.NET forum.
|
|
|
|
|
|
Hi All,
I am developing an application in which I want to get the Cursor position (current x and y positions) in text mode. Using e.X and e.Y in mousemove event I am getting the x,y coordiantes. But how will I get that in text mode.
Regards,
Uma
|
|
|
|
|
What do you mean by text mode?
|
|
|
|
|
I mean I want to find the row and column position at the cursor location. I have a richtextbox. In this control I want to find out the cursor position as I type the text.
|
|
|
|
|
Not really my strong point here, but if you know the number of columns in the textbox and you can get the length of the text, I think you could work out the cursor position from that...
|
|
|
|