|
Hello
I'm working on web application in VS 2005. I need to create well formatted
word document report(word file has tables).
How it should be done?
I simply dont know anything about creating and writing to word document thru c#/vb/ crystal report.
Please someone tell me how to deal with this.
TIA,
Leena
|
|
|
|
|
Hi All,
I'm trying to build some reporting into an app that I've been working on for a while.
The app has a range of class objects in memory, which I want to use to populate the report. In short, I want to push the data to the report at runtime.
I have designed the report structure (and created the .rdlc file), added a report viewer and bound the viewer to the report. However, I cannot seem to access the objects in the report for assignment.
All net searches return info on binding to database tables, but I've found nothing on binding to class objects.
Any ideas / pointers?
Thanks in advance,
John.
|
|
|
|
|
Open the .rdlc file and you should now have a Data menu item in the VS menu. Click Add New Data Source, select Object and go through the wizard.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi Scott,
I can do that, but once a class is in my data sources tab, I can't look at the componants and can't attach them to a part of my report.
In addition, a lot of the data items I have are time-series items. I will want to set a date for the report and include only data items up to that date. Is there a way to create a dataset in code and dynamically attach it to the report?
Thanks,
John.
|
|
|
|
|
If you have your report active in a tab, you should have a Report menu item. You have to use that to add sources to the particular report. Then you should have them as choices when you put components down on the report. If you didn't know already, you have to pass data in as a generic list even if there's only one object that you're working with. And be warned that the editor is NOT NICE when it comes to revising the report, I can't tell you how many times I've had to manually edit the rdlc file to fix something that the automation broke.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi,
I've got this piece of code:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
How can I instantiate a list for the type found above? something like (doesn't work):
System.Collections.Generic.IList<type> list = new System.Collections.Generic.List<type>();
Thanks in advance
|
|
|
|
|
Member 3754905 wrote: How can I instantiate a list for the type found above? something like (doesn't work):
I am not sure I got your question, are you looking to instantiate the type ? Try Activator.CreateInstance()
|
|
|
|
|
No, I've got the type.
I want to make a generic list that contains objects of the type I just found. E.g.:
List<typefound> list = new List<typefound>();
|
|
|
|
|
If the generic type has a default constructor (zero-arg), then all you need do is add a constraint to handle it. Consider this example:
public class CreatableTest<T> where T : new()
{
public static T CreateTestObject()
{
return new T();
}
} The section where T : new() adds the ability to call the default constructor.
|
|
|
|
|
That wont work The type is not known at compile time.
|
|
|
|
|
leppie wrote: That wont work The type is not known at compile time.
Sorry, but it is. Try this sample:
using System;
using System.Collections.Generic;
using System.Text;
namespace MyClass
{
public class Class1
{
public static T Create<T>() where T : new()
{
return new T();
}
}
public class MyTest
{
public MyTest()
{
}
}
} This can be called by:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestHandler
{
class Program
{
static void Main(string[] args)
{
MyClass.MyTest test = MyClass.Class1.Create<MyClass.MyTest>();
if (test != null)
Console.WriteLine("Here I am");
Console.ReadLine();
}
}
} Works fine - it's not useful because other constraints would be useful such as constraining it to a type to get default information.
|
|
|
|
|
Like I said, the type is NOT known at compile time, hence your second snippet will not compile
|
|
|
|
|
Strange - it compiled AND ran when I did it.
|
|
|
|
|
Your code as it is will compile. But in the OP's case, he has no type there yet, so it wont work (you cant just make one there!).
So to wrap it up:
- he loads an assembly
- he gets a type (one that is not known when he compiled the code)
- make a generic List of the runtime type via Type.MakeGenericType, as the type is not known at compile time
|
|
|
|
|
leppie wrote: But in the OP's case, he has no type there yet
Which is why I mentioned that additional constraints would be needed. For instance, he could use IList as a constraint to identify that the item is a list of type T.
|
|
|
|
|
The OP is trying to instantiate a generic class, with only the Type instance for the actual type available. In your example, you were able to pass MyClass as a type parameter, the OP has only typeof(MyClass), which he got through reflection.
|
|
|
|
|
Well spotted - I missed that. That'll teach me not to skim read the question.
|
|
|
|
|
Look at Type.MakeGenericType().
You will have to do something like:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
Type ltype = typeof(List<> ).MakeGenericType(type);
IList list = Activator.CreateInstance(ltype) as IList;
Note: The bolded types are not generic types, you can use a generic IList if the type or its parent or interfaces are known at compile time.
[update] Or simply use an ArrayList or List<object> [update]
modified on Thursday, June 19, 2008 1:24 PM
|
|
|
|
|
Hello,
I have a lot of asp pages and i have to change to search in this pages to know where a specified method is called.
I have tried more program but no one work.
Do someone know the name of a powerfull software that can a good search.
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Windows explorer search (using A word or phrase in file) is good, as is Visual Studio.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I'm using HttpWebRequest & HttpWebResponse classes in my application. I have SSH proxy on my computer which IE or FIREFOX use it to connect to internet. How can I make my application use the same proxy or use the setting in IE? The WebProxy class didn't help me.
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
WebProxy.GetDefaultProxy() although deprecated will return the proxy of IE.
|
|
|
|
|
Hi to all!! Can any body help me abt asterisk ,how to generate call in asteriskwin32 to a local phone in windows xp. How to write call files and entension.conf.
|
|
|
|
|
CP has an article on Asterisk. Search for it.
|
|
|
|
|
Hi,
I want to copy files from one network path to another network path through windows serivce.
I am impersonating the user but it works only for one network path at a time. If I try to impersonate another user the first one becomes invalid.
Is there a way through which we can impersonate two users simulateneously.
I know other way is that I copy file from source network path to local system and then copy it from local system to destination network path i.e impersonating one user at a time but there are other things in my code which will make this too complicated.
I would really appreciate if anybody can help me on this.
Regards,
Rahul Rastogi
|
|
|
|