Newbie Servlet getParameter() Problem!

Hi there i'm trying to upload a file to a tomcat webserver. I'm using the import com.oreilly.servlet.MultipartRequest and that seems to work fine.
My problem is that i need to specify the directory to store the file by getting the users name.
i'm trying to use request.getParameter(user) but this doesn't seem to work. if i get the parameter using the MultipartRequest that works but the problem is that o need to know the user name before i create the MultipartRequest. Heres a copy of my code. if anyone could help i'd REALLY appriciate it!!!
import com.oreilly.servlet.MultipartRequest;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
public class fileupload extends HttpServlet
     public void doPost(HttpServletRequest request,HttpServletResponse response)
                   throws ServletException,IOException
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          try
               String uname      = request.getParameter("user");
               String pass      = request.getParameter("password");
               MultipartRequest multi = new MultipartRequest(request, "C:\\tomcat\\webapps\\301\\galleries\\"+uname,10*1024*1024);
                     database db = new database();
               db.setConnection(); 
               if(db.login(uname,pass))
                    File uploadedFile = multi.getFile("file");
                    InputStream bis = new BufferedInputStream(new FileInputStream(uploadedFile));
                    bis.close();
response.sendRedirect("http://localhost:8080/301/unpack_gallery.jsp?file="+uploadedFile.getName());
          catch(IOException ioe)
               System.out.println(ioe);
} Many Thanks Tom

I'm not familiar with the MultipartRequest package but it seems that you cannot go
easily with that. I think you have few options:
1) use the MultipartRequest package and provide a temporary filename in constructor.
Then get the user name and copy the file from the temporary directory to a appropriate
place with a appropriate name (including the username).
2) Or use jakarta commons file upload package which does the job for your.
Take a look at http://jakarta.apache.org/commons/fileupload/

Similar Messages

  • Servlet Compilation Problem !

    Hi,
    I am just starting to learn servlets and I got problem in compiling them. I got compilation error in
    import javax.servlet.*;statement. Seems that the compiler cannot find the servlet package. I got J2EE 1.4 beta installed on my machine but there is no servlet.jar package. I am using J2SDK 1.4.1_02, J2EE 1.4 beta and Tomcat 4.1.24.
    Can anyone help me with my servlet compilation problem?
    Thanks in advance!
    Josh

    servlet.jar is here :
    <tomcatdir>\common\lib
    add it to your compiler classpath

  • Servlet chaining problem..

    import java.io.*;
        import javax.servlet.*;
        import javax.servlet.http.*;
        public class Deblink extends HttpServlet {
          public void doGet(HttpServletRequest req, HttpServletResponse res)
                                       throws ServletException, IOException {
            String contentType = req.getContentType();  // get the incoming type
            if (contentType == null) return;  // nothing incoming, nothing to do
            res.setContentType(contentType);  // set outgoing type to be incoming type
            PrintWriter out = res.getWriter();
            BufferedReader in = req.getReader();
            String line = null;
            while ((line = in.readLine()) != null) {
              line = replace(line, "<BLINK>", "");
              line = replace(line, "</BLINK>", "");
              out.println(line);
          public void doPost(HttpServletRequest req, HttpServletResponse res)
                                        throws ServletException, IOException {
            doGet(req, res);
          private String replace(String line, String oldString, String newString) {
            int index = 0;
            while ((index = line.indexOf(oldString, index)) >= 0) {
              // Replace the old string with the new string (inefficiently)
              line = line.substring(0, index) +
                     newString +
                     line.substring(index + oldString.length());
              index += newString.length();
            return line;
    What is pre request fo above code to work.
    I had tried this many time but it is not working, what will be calling servlet look like

    And can you explain why your title is "Servlet chaining problem"?

  • Request.getParameter problem

    Did any one faced the problem please provide me a solution I am converting a project to WebSphere. using J2EE jsp 1.1 from NAS,jsp 0.92
    I have a jsp page and I am submitting the form:
    Test.jsp
    <body>
    <form name="frm" method="post" action="TestServlet">
    <INPUT type="CHECKBOX" name="CKBXVCH23" value="A" checked>A
    <INPUT type="CHECKBOX" name="CKBXVCH23" value="B" checked>B
    <INPUT type="CHECKBOX" name="CKBXVCH23" value="C" checked>C
    </form>
    </body>
    TestServlet:
    when i do String str=request.getParameter("CKBXVCH23")
    I am getting only str="A"
    It suppose to give str=A;B;C because I have selected all the three items Its working fine in iPlanet, jsp 0.92
    can anyone know whats the diffenrece.???
    Thanks
    zakir hussain

    If you change the post to a get so you can see what is passed to the servlet you'll see the following parameters are passed:
    CKBXVCH23=A&CKBXVCH23=B&CKBXVCH23=C
    You need to use the
    public java.lang.String[] getParameterValues(java.lang.String name)
    mehod to get an array of all the values associated with "CKBXVCH23"

  • Servlet output problem

    hi
    Im having a problem with reading some data out of my servlet textbox.
    the user pastes some data into the textbox below and tixks the checkbox if
    the first column is headings.
    <BR><TEXTAREA NAME="Paste" ROWS="15" COLS="65"></TEXTAREA>
    <ul>
    <INPUT TYPE ="checkbox" NAME="firstcol" VALUE="First">First name is column name
    //I save the parameters as below
              String table = request.getParameter("Paste");
              String firstcol=request.getParameter("firstcol");
                   out.println(firstcol);
              session.setAttribute("table", table);
              session.setAttribute("firstcol", firstcol);
    //then retrieve them
              String t= (String)session.getAttribute("table");
              String f= (String)session.getAttribute("firstcol");
              if(f.equals("First"))
              ColumnParser.column(t, writer);
              else //(f.equals(null))
              writer.println(t);
    //the problem is it works fine if the user selects the checkbox and the column headings are printed out. But if the user doesnt select the checkbox, instead of the whole data being printed out I get an internal server error! I would be very grateful for any suggestions
    thanks.           

    The "internal server error" means that your code there threw an exception of some kind. You need to look into your servlet container's log files to find out exactly what it was -- there should be a stack trace in one of them. My bet is that you have a NullPointerException, since your code assumes that both parameters will be present in the request and does not check to see if either is null.

  • Servlet cluster problem

    I am having trouble with a wls6.1 cluster. I am trying write a pdf out
              via a servlet. When I run the following code with the cluster turned
              off I have no problems. If I turn it on the servlet is returning no
              data. I am including the servlet and the stack trace in case someone
              can help. GenericFileObject.getTheFile returns a byte array.
              Jeff
              public void service(HttpServletRequest request, HttpServletResponse
              response) throws ServletException, IOException {
              DataOutputStream activityreportOut = new
              DataOutputStream(response.getOutputStream());
                        try {
                        HttpSession session=request.getSession(true);
                        response.setContentType("application/pdf");
                   String fileid = request.getParameter("fileid");
              String type=request.getParameter("type");
                        byte[] buffer;
                   ClientFacadeHome cfhome = (ClientFacadeHome)
                   EJBHomeFactory.getInstance().getBeanHome(Constants.CLASS_CLIENT_FACADE,
              Constants.JNDI_CLIENT_FACADE);
                   ClientFacade cf= cfhome.create();
                        GenericFileObject file =(GenericFileObject)
              cf.getFile(fileid,type);
                   buffer =(byte[]) file.getThefile();
                   activityreportOut.write(buffer);
              catch (Exception e){
                   e.printStackTrace();
              activityreportOut.flush();
              java.io.IOException: Broken pipe
              at java.net.SocketOutputStream.socketWrite(Native Method)
              at java.net.SocketOutputStream.write(Unknown Source)
              at weblogic.servlet.internal.ChunkUtils.writeChunkTransfer(ChunkUtils.java:189)
              at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:165)
              at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:248)
              at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:306)
              at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:197)
              at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:121)
              at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:155)
              at java.io.DataOutputStream.write(Unknown Source)
              at java.io.FilterOutputStream.write(Unknown Source)
              at com.bi.micardis.security.clientaction.ActivityAndScriptServlet.service(ActivityAndScriptServlet.java:41)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2456)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2039)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

              "Subir Das" <[email protected]> wrote:
              >So, Applet#1 will always talk to the servlet hosted by WLInstance#1 and
              >Applet#2
              >will always talk to the servlet hosted by WLInstance#2.
              This statement is not entirely true.
              Suppose WLInstance#1 were to be brought down (for whatever reason), Applet#1 will
              then talk to servlet hosted by WLInstance#2.
              Server pinning could be modified by different load balancing algorithms, configurable
              via containers (or hardware).
              So don't count on which servlet instance your applet is going to be served by.
              Instead consider to give a second look into the design of the servlet data structure
              (object):
              1.Read from data store, if it has been persisted.
              2.If the data is client related then consider sticking the data into session, which
              would then replicate to other WL instances.
              3.Stateless EJB in a cluster ? Don' know much about this(yet).
              My 2 cents..Good luck.
              Rama
              

  • Tomcat Servlet Security Problem? : Start Excel with NJAWIN - COMObjects

    I get an exception when I start my programm as servlet , as application it works just fine (when I start it as Servlet in the internal Tomcat from JBuilder it also works fine).
    Application app = new Application(Application.progID); // interfaces built with java2com for Excel
    com.develop.jawin.COMException: 8000ffff: CoCreateInstance for "{024500-00-0000-c000-000000000046}" failed
    at com.develop.jawin.win32.Ole32.CoCreateInstance(Unknown Source)
    at com.develop.jawin.win32.Ole32.GetFromProgID(Unknown Source)
    at com.develop.jawin.DispatchPtr.<init>(Unknown Source)
    at excel2pdf.Excel._Application.<init>(_Application.java:31)
    Actually Excel is started but as SYSTEM and not as my Username. Perhaps there's a problem with the security policy, I already gave all rights to catalina for my whole projekt( each directory of it). Have smb already had this problem? Any Ideas?

    Thanks for answering
    In my case I think I cannot use POI because I need Excel
    and a Virtual Printer , so I can convert excel files with exactly the same
    format to PDF. POI is suppose better idea for creating or manipulating
    OpenOffice files (they are working together with OO on file formats),
    and unfortunately OpenOffice doesnt work fine with charts (I already had
    this solution, openoffice-server and Uno ).
    It must be smth with Tomcat-Configuration or security, because my
    programm is working with the internal tomcat-server of JBuilder, and
    as application too. In both cases Excel is started with my username and
    not SYSTEM (my tomcat server is started as service, perhaps thats why
    by starting excel from my servlet Excel is by user - SYSTEM).

  • Applet-Servlet Communication problem EOFException

    Hi! i´ve been searching and searching through forums because it seems this problem is very common, but none of the solutions i´ve seen so far suits me, so i´m here looking for some help because i´ve been stuck one week with this. First of all sorry if my english isn´t the best... i´m a bit rusty...
    Well, i had some code that worked perfectly, but i needed to perform some changes because i needed the servlet to send more info to the applet, and here started the problems, when i made the changes it started to throw EOFException when i was trying to read the InputStream, and furthermore when i came back to the original code it started to throw the exception in the same place too
    So here i am... don´t know what to do now and i entrust to you to give me some tips.
    Here comes some code. This is the original code, the one that runned but it doesn´t run right now
    Applet:
    public ListasComponentesSeleccionables cargarListasComponentes( ) throws IOException, ClassNotFoundException {
              String serv = "/Desaladora/cargarListasComponentesApplet.do";
              String host = Principal.documentBase.getHost( );
              URL direccion = new URL( "http", host, 8080, serv );
              // Create conection
              URLConnection connection = direccion.openConnection( );
              connection.setDoInput( true ); 
              connection.setDoOutput( true );
              connection.setUseCaches( false );
              connection.setRequestProperty( "Content-Type", "application/x-java-serialized-object" );
              ObjectOutputStream output;
              output = new ObjectOutputStream( connection.getOutputStream( ) );
              output.writeObject( new Boolean(true) );
              output.flush( );
              output.close( );
              ObjectInputStream input = new ObjectInputStream( connection.getInputStream( ) ); //<-- Here is the problem
              ListasComponentesSeleccionables response = new ListasComponentesSeleccionables( );
              response = ( ListasComponentesSeleccionables ) input.readObject( );
              return response;
         }Servlet:
    ublic class CargarListasComponentesAppletAction extends Action {
    public ActionForward execute(     ActionMapping mapping,
                                                     ActionForm form,
                                                     HttpServletRequest request,
                                                     HttpServletResponse response )
                            throws ServletException, IOException, Exception  {
              InitialContext context = new InitialContext();
              SensorManagerService sensor_service;
              ActuatorManagerService actuator_service;
              Globals.LOGGER_SECURITY.debug( "Entering ACTION 'CargarListasComponentesAppletAction'" );
              response.setContentType("application/x-java-serialized-object");
              try
                   ObjectInputStream bufferentrada = new ObjectInputStream(request.getInputStream());
                   Boolean peticionOK = (Boolean)bufferentrada.readObject();
                   ObjectOutputStream buffersalida = new ObjectOutputStream(response.getOutputStream());
                   sensor_service = ( SensorManagerService ) context.lookup( "desaladora/SensorManagerServiceBean/local" );
                   ArrayList<AlarmConnectedSensorDTO> sensorList = sensor_service.findAllSensorsToAlarms();
                   actuator_service = ( ActuatorManagerService ) context.lookup( "desaladora/ActuatorManagerServiceBean/local" );
                   ArrayList<AlarmConnectedActuatorDTO> actuatorList = actuator_service.findAllActuatorsToAlarms();
                   buffersalida.writeObject( crearListasSeleccionables(sensorList, actuatorList) );
                   buffersalida.flush();
              catch(Exception e)
                   System.out.println("Error en la trasmision de datos");
              return null;
         private ListasComponentesSeleccionables crearListasSeleccionables(ArrayList<AlarmConnectedSensorDTO> sensorList,
                    ArrayList<AlarmConnectedActuatorDTO> actuatorList) {
              Vector<Integer> vectorSensores = new Vector<Integer>();
              Vector<Integer> vectorActuadores = new Vector<Integer>();
              for(AlarmConnectedSensorDTO sensor : sensorList) {
                   vectorSensores.add(sensor.getIdSensor( ));
              for(AlarmConnectedActuatorDTO actuator : actuatorList) {
                   vectorActuadores.add(actuator.getIdActuator( ));
              ListasComponentesSeleccionables listasComponentesSeleccionables =
                                  new ListasComponentesSeleccionables(vectorSensores, vectorActuadores);
              return listasComponentesSeleccionables;
    }i´ve been running some test in another computer, and this code simply works, but it doesn´t work in the machine i usually work.
    Maybe someway the stream get corrupt? the info i´ve been trying to send and started throwing the exception may still be in the stream? I don´t know what to think right now.
    Hope someone has any idea, thankyou.

    I dont see the problem. However, I suggest you change this;
    System.out.println("Error en la trasmision de datos"); t
    to e.printStackTrace() to see what it is doing when it stops working.
    I also suggest peppering your code with System.out.println() statements to see what it is doing just before stopping.
    Also, try your code with a brand new file with only a few characters in it. If it works, add to it some of your originial file content until it stops working. This way, you can determine if its the file size that is causing the crash or something in the file content. If all else fails, study java I/O and try some other way to read/write the file. You can also try a different browser. If it works, its the browser. Still having problems? Create a new project with a simple applet and file read/write program and get that working. That way, all the other stuff in your original project isn't in the way.

  • Servlet mapping problem in Resin, very weird!

    ENV: resin 2.1.6 on windows 2000
    1, I copied all the files and folders in $resin/doc/java_tut to $resin/webapps
    2, I did a little change to $resin/conf/resin.conf
    In the old resin.conf, there is a lot about the '/' webapp.
    <web-app id='/'>
    <classpath id='WEB-INF/classes'
    source='WEB-INF/classes'
    compile='true'/>
    </web-app>
    I replaced it just with
    <web-app id='/'/>
    3, I tested the 'java_tut' webapp
    http://localhost:8080/java_tut/servlet/example.servlet.basic.MappingServlet
    works well.
    http://localhost:8080/java_tut/exact
    works well, too.
    4, Then I tested the '/' webapp
    http://localhost:8080/servlet/example.servlet.basic.MappingServlet
    works well.
    but
    http://localhost:8080/java_tut/exact
    returns error code 404
    what's the problem?

    don't you need to get rid of the java_tut bit?

  • How to send Oracle rowid to servlet? | Problem with national characters.

    There is same possibility how to send rowid to servlet?
    I have now definition like this:
    <af:image source="/imageservlet?Par1=#{bindings.Col1.inputValue}"/>
    But If column contents national characters, servlet methods obtained changed these characters.
    My idea is to use not primary key for row, but use oracle rowid. It is simply possible?
    Use something like this:
    <af:image source="/imageservlet?Rowid=#{bindings.Rowid}"/
    Or Do you have ideas how to solve problem with national characters ?
    Thanks
    FiL

    Hi,
    Although your workaround works.
    I think this is a simple encoding problem.
    I simply need to make sure all parameters and pages are encoded with a char set which contains the national characters you mentioned.
    This is a bit dependent on the exact technology your using, but most can be done via the web.xml:
      <jsp-config>
          <jsp-property-group>
              <url-pattern>*.jsp</url-pattern>
              <page-encoding>UTF-8</page-encoding>
          </jsp-property-group>
      </jsp-config>     This forces all JSP pages to be encoded in UTF-8
    Adding the following parameter sometimes helps as well, although I think this one is a bit dated:
    You said your using a servlet so your servlet needs a similar block for its pattern
      <context-param>
        <param-name>PARAMETER_ENCODING</param-name>
        <param-value>UTF-8</param-value>
      </context-param>If you want to be 100% sure the encoding is set right make sure thepages contain:
    <%@ page contentType="text/html;charset=utf-8"%>Or depending on your view technology the syntax can be a bit different
    -Anton

  • HttpServletRequesr.getParameter :  Problem with double quotes

    Hi,
    I am having a problem in accessing "POST" parameters which have "quotes" in it. For example,
    If the post parameter named param contains Hello "(hw)" World, the getParameter returns Hello instead of Hello "(hw)" World.
    I'm not sure if this is related to encoding. Encoding seem to be ISO-8859-1 (got from getCharacterEncoding).
    Any clue of the problem ?

    How do you send the post parameters. Do you send them usign a html from or are you sending them programaticaly. In that case make sure the keys and values are URL encoded with UTF-8

  • Servlet configuration problems ..

    Hi
    I am a new member starting with Java Servlets:
    I have a problem with Configuring the Servlet on the J2EE Application server.
    Here is the Servlet code ...
    package mypackage;
    public class ShowParameters extends HttpServlet {
        public void doGet(HttpServletRequest request, HttpServletResponse response)         throws ServletException, IOException { .... }And this is the web.xml file
        <servlet>
            <servlet-name>ShowParameters</servlet-name>
            <servlet-class>mypackage.ShowParameters</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>ShowParameters</servlet-name>
            <url-pattern>/ShowParameters</url-pattern>
        </servlet-mapping>And the HTML file is ....
    <FORM ACTION="ShowParameters">
        First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
        Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
        Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
        <CENTER>
            <INPUT TYPE="SUBMIT">
        </CENTER>
    </FORM>I have set the CLASSPATH variable t /build/mypackage/
    I get two erros:
    Wrapper cannot find servlet class ..
    ClassNotFound exception ...
    Also, how do I compile " the servlet class file with the line; package hello; " with the package name
    I would appreciate any help ..
    Thanks
    N

    I am trying to invoke a servlet from an HTML page.
    Method 1
        <FORM ACTION="ThreeParams" METHOD="GET">
            First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
               <CENTER>
            <INPUT TYPE="SUBMIT">
        </CENTER>
        </FORM>Method 2
    <td><a href="Threeparams">Execute</a></td>Method 1 does not work but Method 2 does. But Method 2 does not transmit param1 to the server.
    Any thought on how to get it correct?
    Rgds
    N

  • Servlet side problem

    hi there,
    i have managed to get my mipd program talking 2 a tomcat server, but i have run into the following problem:
    the servlet has at initiation a buffer called int l = 0; and increment the l value by 1 , this is fine but when i get another phone 2 connect to the server, i want the value of l to increment to 2, instead the value resets to 0 and then increments by 1 giving me the final value of 1 yet again on the second phone
    here is the code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class testing3 extends HttpServlet{
    int l;
    public testing3(){ l=0;}
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
    InputStream in = req.getInputStream();
    PrintWriter out = res.getWriter();
    String rankstring = "sent by server";
    int requestlength = req.getContentLength();
    if(l==0){
    if(requestlength > 0 ){
    for(int i=0;i<requestlength;i++){
    int c = in.read();
    if(c==-1)break;
    l++;
    else if(l==2)
    out.write(rankstring);
    System.out.println("l value is" + l);
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException{
    doPost(req,res);
    how do i get around this problem?advice will be greatly appreciated
    regards

    i think you want to number of hits kind of value...
    make that variable static
    you should get the value that you want
    [email protected]

  • Servlet intercommunication problem

    Hi,
    I have a problem regarding servlet intercommunication.
    What I m doing is : I have an HTML form in which user enters some data and submits it. Servlet_1 is called , it gets all the parameters and displays all data in the form of an html form again. Now, if the user clicks on "SAVE" button , only then Servlet_2 should get called and that data should be stored in database .
    I m having problem while saving data.I just lose track of data entered by the user somewhere between the servlets.
    How should I get the data enetered by the user previously, and in what form I should store it to access it later on through any servlet?
    Please help.
    Regards
    Shweta

    I suggest other than showing the data on the HTML returned by Servlet_1, you created hidden values of the data submitted into the displayed form. In this way, the data would be resent to Servlet_2 when Save is pressed.
    Alternatively, you can use a Session to store the contents of the submitted information. (this will enable you to access it later on any servlet)

  • Servlet Execution Problem

    I have installed Apache Tomcat/6.0.10. Can you please tell me what is the process for running servlet in it. There is no any problem in the compilation of servlet.
    Rakesh Kumar

    see this thread
    Don't just re-post the question because you didn't like the answer you got before. Looks like a perfectly acceptable answer to me

Maybe you are looking for

  • How to create a f4 help using function module.

    Hi,     I want to create an f4 help with out using match code objects.How can i do it ? . Is there  any function code for it ?.

  • Tagging

    Adding the tag count next to the tags is a big plus (+) for the new forum upgrades! It also allowed a little bit of analysis, which led to a couple of ideas: In the top 100 tags, about a quarter are "bogus". The top bogus tags are "the, to, I, and, a

  • It is possible to boot a mac mini from keyboard?

    I need to boot my mac mini from Kb, it is possible?

  • Redeploying with 7.0.4 in redhat 7.3

    I'm having some trouble with redeployment of ear files. I'll describe what is happening: 1 - I deploy my appl, all works OK 2 - I make a few changes in the body of an auxiliary class (not part of an Entity nor a Session) 3 - I make my ear from scratc

  • How to persist updated DataGridTemplateColumn value

    I am new to WPF and facing some issues with datagrid . My ViewModel has an ObservableCollection Report Of class T_Reports. //EF generated code  public partial class T_Reports         public int ReportID { get; set; }         public string ReportName