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:
Expand|Select|Wrap|Line Numbers
- <asp:objectdatasource id="ObData2" runat="server" dataobjecttypename="EmpData" typename="Employee" selectmethod="getEmployee" ><selectparameters>asp:controlparameter controlid="employeeid" name="eId" propertyname="text" type="string" /></selectparameters>
- <asp:gridview id="GridView2" action="databind" runat="server" datasourceid="ObData2"datakeynames="EmployeeID" allowpaging="True" autogenerateeditbutton="True" autogeneratecolumns="True"emptydatatext="No Records" allowsorting="True" >
Expand|Select|Wrap|Line Numbers
- [DataObjectMethod(DataObjectMethodType.Select)]
- public void getEmployee(string eId)
- {
- MySqlCommand cmd = new MySqlCommand();
- try
- {
- DB_Connection conn = new DB_Connection();
- cmd.Connection = (MySqlConnection)conn.DBConnect(); cmd.CommandText = "getEmployee";
- cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("EMPLOYEEID", eId);
- cmd.ExecuteNonQuery();
- }