|
hai,
i m using ASP.NET with C# (.net 2005, 2.0 framework)
here i have a datagrid which contains 10 columns.
the 4,5,8 column contains date in the format (7/23/2007 12:00:00 AM). i want to change those date in (23-Jul-2007). the major key point in this is....
1. Fields are dynamic, so i cant fix in DATABOUNDCOLUMN
2. The placement should be the same (i.e, 4,5,8 columns)
3. The data are filled to datagrid from SQL Server.
How to achieve it? help me...... - KARAN
|
|
|
|
|
Hi can acheive that in two ways.
John Sundar wrote: i want to change those date in (23-Jul-2007).
1) while writing query to retriew data from SQL server you need to use convert function.
eg: select convert(varchar,DateColumn,105) from tablename
2) In databound of datagrid coloum u can foramt.
Regards,
Sandeep Kumar.V
|
|
|
|
|
Thanks sandeep kumar.V
but the thing i need is "DD-MMM-YYYY" (this exact format).
and also i need the alias name also... my exact query.....
select convert(varchar,column1 as "Test column",106) from tbl_name
how to achieve it?????
|
|
|
|
|
John Sundar wrote: select convert(varchar,column1 as "Test column",106) from tbl_name
the query is not correct.....
select convert(varchar,column1,106) as "Test column" from tbl_name
Regards,
Sandeep Kumar.V
|
|
|
|
|
Thanks a lot sandeep... i achieved 90% of my requirement.
but i cant get the separator (any separator is OKAY)
the output is "25 Jan 2007". my requirement is "25-Jan-2007".
is there anyway to achieve it?, so that my requirement will get fulfilled 100%
modified on Saturday, April 12, 2008 3:12 AM
|
|
|
|
|
Hi.....
I think there is no formatter to format like that......
in dotnet you can acheive that.....like.....
eg:
<asp:BoundField DataFormatString="{0:dd-MMM-yyyy}" DataField="ShippedDate"<br />
HeaderText="Shipped Date" />
Regards,
Sandeep Kumar.V
|
|
|
|
|
Thanks a lot sandeep... nice to meet you.........
|
|
|
|
|
I found the answer in query itself sandeep... just refer it
SELECT REPLACE(CONVERT(VARCHAR, column_name, 106), ' ', '-') as "column 1" from tbl_name
Take care...
|
|
|
|
|
hai,
i m using ASP.NET with C# (.net 2005, 2.0 framework)
here i create a directory named "A" and some files are in this folder (say... A1,A2).
and outside of "A" folder there are some files (out1,out2).
how can i specify the path to fetch the file from A1 to out1???
how to achieve it?
help me - KARAN
|
|
|
|
|
hi....
you can achieve that by using namespaces.
Give same namespace for all the pages that u want to access.
Regards,
Sandeep Kumar.V
|
|
|
|
|
kindly could u give me an example, so that i can understand clearly.
And also can u specify by means of the example which i have posted?.
thank you...
|
|
|
|
|
Hi...
for the file A1 which is in the folder suppose give namespace as
namespace TestNamespace
{
public class A1
{
............
}
}
for the file which is out side the folder give same name space like...
namespace TestNamespace
{
Public class out1
{
}
}
now if you want ot access any for the files you can directly call that cllas name in your class file....
like....
namespace TestNamespace
{
Publc class out2
{
out1 o=new out1();
A1 a=new A1();
}
}
Hope with this you can get some thing......
Regards,
Sandeep Kumar.V
|
|
|
|
|
wow...... S sandeep.. i got it.. this is i needed.
and another clarification sandeep?
suppose my full path is : c:\inetpub\wwwroot\project\tet_pr.ascx
another file path is : c:\inetpub\wwwroot\project\output\file1.ascx
how to switch from one file to another by using the below statement?
int a;
if (a == 1)
this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("te_pr.ascx"));
else
this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("file1.ascx"));
help me .
thanks for understanding......... - KARAN
|
|
|
|
|
John Sundar wrote: this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("file1.ascx"));
i guess above code should be like below one......
this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("\output\file1.ascx"));
Regards,
Sandeep Kumar.V
|
|
|
|
|
Thanks sandeep.. to fetch the te_pr.ascx from file1.ascx???????????
how to achieve it?
|
|
|
|
|
give same namespace for both user controls then same as classes you can access them.....
Regards,
Sandeep Kumar.V
|
|
|
|
|
can u tel me with the example sandeep?? plz..
suppose my full path is : c:\inetpub\wwwroot\project\tet_pr.ascx
another file path is : c:\inetpub\wwwroot\project\output\file1.ascx
how to switch from "file1" to "tet_pr" while i m working in "file1.ascx"
int a;
if (a == 1)
this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("te_pr.ascx"));
else
this.MenuPlaceHolder.Controls.Add((UserControl)LoadControl("file1.ascx"));
help me .
thanks for understanding......... - KARAN
|
|
|
|
|
This seems incredibly nasty, but I'd say if you need to do this, your best bet is to set what path leads to a particular control, in your resources, and swap resource files as needed. As someone else said, odds are you need to name the classes the same if you want to be able to use them when you swap them out like this. OR a better idea again is to simply define an interface that the controls you're using will have in common and access them via that interface.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i have a gridview with a select link in first column. and i want when i select a row i get the select row values that are in cells. how can i do this . can anybody tell me please
|
|
|
|
|
Where do you want them, client side or server side ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
In your gridview use the OnSelectedIndexChanging-event
aspx:
OnSelectedIndexChanging="myGridiew_OSIC"
in code behind:
protected void myGridiew_OSIC(Object sender, GridViewSelectEventArgs e)
{
myGridView.SelectedIndex = e.NewSelectedIndex;
String Field1 = myGridView.Rows[e.NewSelectedIndex].Cells[0].Text;
etc...
myGridView.SelectedIndex = -1;
}
|
|
|
|
|
how can i retrive value of rich text box in html format because i want store this value in data base
plz suggest me
thanks........
krishna veer singh
|
|
|
|
|
There is no inbuilt rich textbox available for ASP.NET. Taking HTML depends on the control you are using.
|
|
|
|
|
I'm trying to work with Excel objects in C# for ASP .NET 2.0. I am receiving the following error:
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.Sheets.Add(
I am trying to follow the article here but it is in Visual Basic. The .Add function does not include any parameters but in C#, it seems I must pass the 4 parameters. (Object before, object after, count, and object type).
The article for reference is at: Generating Excel Reports in ASP .NET 2.0[^]
Unfortunately, I will not be able to post any code, but does anyone know of any good articles on how to work with excel to generate spreadsheet that is generated from data and then the chart added in C#?
Thanks
|
|
|
|
|
Hi,
Can you give little more information? Are you sending the data which is in grid to excel file? If so, I have code which exports to .CSV file from a gridview...
If your question is the same, I can share the code for you.
Thanks...
|
|
|
|