473,785 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

6 New Member
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:

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 2156
jhardman
3,406 Recognized Expert Specialist
moved to .NET forum
Sep 27 '07 #2
nateraaaa
663 Recognized Expert Contributor
Have your tried using the debugger to find out why no records are displayed?

Nathan
Sep 27 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
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
5816
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. What I am trying to do is to only show the data sets chosen by the user. So for example if the user checks Item1 in the CheckBoxList then only the datasets that have Item1 set to True should be listed in the GridView. Here is what I tried: ...
7
5472
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 loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when looping through the GridView, it doesn't
4
1288
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 records. My question: What is the best way to display the product record with the respective image record(s)? Using a FormView for the product record and a GridView/DataList for the image record(s)? Or, writing own code (using Table, Row, Cells and...
3
11721
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 work properly in a gridview, viewstate must be enabled. So, in order to minimize the size of viewstate for a page, I will sometimes turn off viewstate for each control in template columns. That means that the gridview must be databound on each...
2
10611
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 which comes from the database to make a link with the syntax http://server/work_order.asp?WorkOrder=12345678&Site=NYC but I cannot get the NYC value to work from a request.querystring when submitted
1
1850
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 resultsets in Gridview. For ex., in the form I am entering contract id and running the query for that contract id. If results found then use that contract id to run the second query and show the results in gridview.
4
2070
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 three row table with paging. How does this translate to ASP.NET - or - what ASP.NET tools do I use to accomplish this and how. Thank you.
0
1370
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 entered record in the database. view click event it should saw me all the details except the id of the company. The data is displayed in the gridview. How should i pass this ?? <asp:GridView ID="CompanyGridView" runat="server"...
2
4136
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 the tables but the search needs check 3 or 4 tables. Do I need to create a new DataTable which has the columns from both the tables so I can display in the Gridview or can I get the columns somehow from the DataSet without creating a new table? I...
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.