how to display one filtered record in gridview (ASP .NET & C#)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newbieAl
    New Member
    • Sep 2007
    • 6

    how to display one filtered record in gridview (ASP .NET & C#)

    I have a stored procedure in mysql and I am calling it via a method and objectdatasourc e. I have two select methods. One that gets a list of employees and the other that gets one specific employee by passing the employee id via a parameter.

    I have two gridviews, one for displaying all employees and one for displaying one employee record. The user should be able to enter the employee id in the textbox and the gridview should display the employee's record. My code is working for displaying all employees but not for displaying one specific employee. The code compiles but does not display any info. Here is my code:

    [code=asp]
    <asp:objectdata source id="ObData2" runat="server" dataobjecttypen ame="EmpData" typename="Emplo yee" selectmethod="g etEmployee" ><selectparamet ers>asp:control parameter controlid="empl oyeeid" name="eId" propertyname="t ext" type="string" /></selectparameter s>
    [/code]

    [code=asp]
    <asp:gridview id="GridView2" action="databin d" runat="server" datasourceid="O bData2"datakeyn ames="EmployeeI D" allowpaging="Tr ue" autogenerateedi tbutton="True" autogeneratecol umns="True"empt ydatatext="No Records" allowsorting="T rue" >
    [/code]

    [code=cpp]
    [DataObjectMetho d(DataObjectMet hodType.Select)]
    public void getEmployee(str ing eId)
    {
    MySqlCommand cmd = new MySqlCommand();
    try
    {
    DB_Connection conn = new DB_Connection() ;
    cmd.Connection = (MySqlConnectio n)conn.DBConnec t();
    cmd.CommandText = "getEmploye e";
    cmd.CommandType = CommandType.Sto redProcedure;
    cmd.Parameters. Add("EMPLOYEEID ", eId);
    cmd.ExecuteNonQ uery();
    }[/code]
    Last edited by Frinavale; Sep 27 '07, 08:24 PM. Reason: Added [code] tags to make more legible
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    moved to .NET forum

    Comment

    • nateraaaa
      Recognized Expert Contributor
      • May 2007
      • 664

      #3
      Have your tried using the debugger to find out why no records are displayed?

      Nathan

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Double check that your stored procedure is returning the data.
        (Double check that it works...maybe using Query Analyzer or something)

        -Frinny

        Comment

        Working...