Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm facing a problem in displaying a result set of a stored procedure in a grid. Below are my code details:
Stored Proc returns 3 columns and 8 rows which I verified while debugging but those records re not getting displayed even after i set EnableViewSet and Visible property as 'True'. I have placed the binding portion under the Button Click event as below.I didn't get any error message when executing,

VB
Dim cmd As New OracleCommand()
       Dim DA As New OracleDataAdapter(cmd)
       Dim DS As New DataTable
       Details_grd = New GridView
       cmd.Connection = con
       cmd.CommandType = CommandType.StoredProcedure
       cmd.CommandText = "Details_display"
       cmd.Parameters.Add(New OracleParameter("Services", OracleType.VarChar)).Value = RadioButtonList1.SelectedItem.Value
       cmd.Parameters.Add(New OracleParameter("result", OracleType.Cursor)).Direction = ParameterDirection.Output
       con.Open()
       DA.Fill(DS)
       Details_grd.DataSource = DS
       Details_grd.DataBind()
       con.Close()


Anyone,pleas help me in understanding the missing/wrong portion in the above snippet.Thanks in advance,

Priya
Posted
Comments
Kreagan Naicker 30-Jan-12 16:34pm    
Hi Priya.

I've noticed that you've created a GridView called Details_grd, is this being used to be displayed on a form / web page?

How are you displaying the GridView on your form / web page?

Normally you would assign and bind the DataTable you've populated above to a GridView on a form / web page unless you are dynamically creating the GridView.
Priyavadhanam 31-Jan-12 11:54am    
Kreagan,

Yeah, the gridview named as 'Details_grd' is displayed in a web page.
I have placed the gridview in the aspx file which needs to be populated with the proc result set. I have placed this code under button click event in aspx.vb file.

There shouldn't be an issue with this design flow, am I?



Priya,

Don't know whether it would work.
remove the object Creation of the Gridview.
You can manually pull down a gridview from toolbox
and bind it to datasource.
if name of gridview is gridview1 then
gridview1.DataSource=dataset;
gridview1.DataBind();

May be the object creation is the problem after all.
Happy Programming:-)
 
Share this answer
 
v2
Comments
Rajesh Anuhya 2-Feb-12 3:42am    
Code tags added
Arun Varghese 2-Feb-12 3:47am    
Thank you
Priyavadhanam 2-Feb-12 11:49am    
Hi, Th statement "Details_grd = New GridView" was the real culprit in my code.
On removing the statement the above code worked fine.
Thanks for the solution :)
Your Code Seems Fine try this code in your page load event.
Check whether it works.
 
Share this answer
 
Comments
Priyavadhanam 31-Jan-12 12:24pm    
No Arun, it didn't turn fruitful.
Guess something is missing somewhere..
Kreagan Naicker 1-Feb-12 6:48am    
If I'm not mistaken you are creating a new GridView object and then calling the databind method so that it can display the related information.

The problem is that this is a new object and has no relation to the aspx page.
What is the grid on the aspx called?

What ever it is named, you need to call the DataBind method against that object instead of creating a new object.
Priyavadhanam 2-Feb-12 11:46am    
Yeah, u r correct Kreagan..
the new object creation for the Grid view was causing this problem, on removing that statement i got what i was expecting.. thanks for your comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900