asp.net网格视图数据绑定 [英] asp.net grid view data binding

查看:71
本文介绍了asp.net网格视图数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我在页面加载事件中有此代码

guys i have this code in the page load event

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



我看不到页面上的网格,没有数据检索
但是当我在sqlserver中执行sql时,我有4行是什么意思



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

推荐答案

GRD1.DataSource = SqlDataSource2
              GRD1.DataBind()


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


看看:
http://www.devexpress.com/Support/Center/p/Q290537.aspx [ ^ ]

OR
请尝试以下方式:
have a look at :
http://www.devexpress.com/Support/Center/p/Q290537.aspx[^]

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


然后我将SqlDataSource绑定到GridView:


Then i bind the SqlDataSource to a GridView:

GridView1.DataSource = ds;
           GridView1.DataBind();


这篇关于asp.net网格视图数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆