Click here to Skip to main content
15,041,548 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
guys i have this code in the page load event

VB
SqlDataSource2.SelectCommand = "SELECT EMPNO,EMPNAME FROM EMPLOYEE"
                SqlDataSource2.DataBind()
                GRD1.DataBind()


i cant see the grid on the page no data retrieves
but when i execute sql in sqlserver i have 4 rows what is the point
Posted
Comments
sriman.ch 1-Dec-11 5:16am
   
Where you are assigning datasource to gridview?

VB
GRD1.DataSource = SqlDataSource2
              GRD1.DataBind()
   
Comments
ahmad7_8 4-Dec-11 3:39am
   
i try all solution above but there is strange thing i don't what to do
my SqlDataSource2 is build by wizard ok
SQL
SqlDataSource2.SelectCommand = "SELECT EMPNO,EMPNAME FROM EMPLOYEE"
                SqlDataSource2.DataBind()
                GRD1.DataSource = SqlDataSource2
                GRD1.DataBind()
   
Comments
[no name] 1-Dec-11 21:09pm
   
my 5.
ahmad7_8 4-Dec-11 3:39am
   
i try all solution above but there is strange thing i don't what to do
my SqlDataSource2 is build by wizard ok
have a look at :
http://www.devexpress.com/Support/Center/p/Q290537.aspx[^]

OR
try in the following way :
C#
string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName;
            
SqlDataSource ds = new SqlDataSource(strProvider, strConn);
            ds.SelectCommand = "SELECT * FROM rammekategori";

Then i bind the SqlDataSource to a GridView:

C#
GridView1.DataSource = ds;
           GridView1.DataBind();
   
Comments
ahmad7_8 4-Dec-11 3:39am
   
i try all solution above but there is strange thing i don't what to do
my SqlDataSource2 is build by wizard ok
Ajay238 3-Dec-13 12:03pm
   
It saying Connection string has not been initialializedddd!!!>>>??? where to open the connection and close??
i try all solution above but there is strange thing i don't what to do
my SqlDataSource2 is build by wizard ok
   
Comments
RaviRanjanKr 1-Dec-11 14:24pm
   
A suggestion :- its not a good practice to post your feedback or comment as an answer. you can use have a question or Comment.
USE SqlCommand object to run the query. that will be a good approach and fill dataset using SqlDataAdapter. and set dataSource to dataset object and bind funcion of grid.
   
v2

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