473,410 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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 objectdatasource. 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:

Expand|Select|Wrap|Line Numbers
  1. <asp:objectdatasource id="ObData2" runat="server" dataobjecttypename="EmpData" typename="Employee" selectmethod="getEmployee" ><selectparameters>asp:controlparameter controlid="employeeid" name="eId" propertyname="text" type="string" /></selectparameters>
  2.  
Expand|Select|Wrap|Line Numbers
  1. <asp:gridview id="GridView2" action="databind" runat="server" datasourceid="ObData2"datakeynames="EmployeeID" allowpaging="True" autogenerateeditbutton="True" autogeneratecolumns="True"emptydatatext="No Records"   allowsorting="True"  > 
  2.  
Expand|Select|Wrap|Line Numbers
  1. [DataObjectMethod(DataObjectMethodType.Select)]        
  2. public void getEmployee(string eId)       
  3.  {            
  4. MySqlCommand cmd = new MySqlCommand();            
  5. try           
  6.  {                
  7.     DB_Connection conn = new DB_Connection();                
  8.     cmd.Connection = (MySqlConnection)conn.DBConnect();                        
  9.     cmd.CommandText = "getEmployee";                
  10.     cmd.CommandType = CommandType.StoredProcedure;                    
  11.     cmd.Parameters.Add("EMPLOYEEID", eId);                
  12.     cmd.ExecuteNonQuery();                            
  13. }
Sep 26 '07 #1
3 2136
jhardman
3,406 Expert 2GB
moved to .NET forum
Sep 27 '07 #2
nateraaaa
663 Expert 512MB
Have your tried using the debugger to find out why no records are displayed?

Nathan
Sep 27 '07 #3
Frinavale
9,735 Expert Mod 8TB
Double check that your stored procedure is returning the data.
(Double check that it works...maybe using Query Analyzer or something)

-Frinny
Sep 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rob | last post by:
Here is my scenario: One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView. Then I have a database that has the columns Item1 and Item2 (among others) with the data type bit....
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
4
by: Guy | last post by:
I'm a little bit confused as what is the bes way to achieve the following: I have 2 database tables, table 1 product en table 2 image. For every product record there can be 0-1 or more image...
3
by: AG | last post by:
Below is code (slightly modified and converted to VB) that was provided to me in response to another post. I am using it to demonstrate another problem. In order for paging and other features to...
2
by: Ixnay | last post by:
Thanks in advance for any help you can give me on this. I am trying to include the value from a request.querystring in the DataNavigateUrlFormatString I am able to include one of the values...
1
by: mamun | last post by:
Hi All, I am doing it for the first time in C# (using Visual Studio 2005), First I need to check if data exists in a table for a variable. If so then run the second query and display the...
4
by: seth_hickel | last post by:
With other solutions I would get a recordset, read each record and display data by formating my html as I wanted to display values of each record. I am trying to display data in a three column...
0
by: Riaaaa | last post by:
I have created the form for entering the company details with its general information in asp.net C# 2005. I have two buttons that form on the submit click event it should saw the newly / last...
2
by: J055 | last post by:
Hi I need to search a number of DataTables within a DataSet (with some relationships) and then display the filtered results in a GridView. The Columns that need to be displayed come from 2 of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.