如何绑定数据网格 [英] How to bind a datagrid

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

问题描述

你好

我了解如何绑定网格视图以在grid

Hello

i wnat to know How to bind a grid view to display data in grid

推荐答案

// Just this much
myGridView.Datasource = myDataTable;
myGridView.DataBind();


参考:
MSDN:GridView概述 [ MSDN:GridView类 [ ^ ]


Refer:
MSDN: GridView Overview[^]
MSDN: GridView Class[^]


HI,
尝试这样,但是更改连接字符串并按您自己的方式查询.

try like this, but change the connectionstring and query as yours.
void BindGrid()
      {
          string strSQLconnection = "Data Source=SERVERNAME;Initial Catalog=DBNAME;Integrated Security=True";
          SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
          SqlCommand sqlCommand = new SqlCommand("select * from TABLE", sqlConnection);
          sqlConnection.Open();

          SqlDataReader reader = sqlCommand.ExecuteReader();

          GridView1.DataSource = reader;
          GridView1.DataBind();
      }


http://msdn.microsoft.com /en-us/library/fkx0cy6d.aspx [ ^ ]



http://www.java2s.com/Tutorial/ASP.NET/0380__Data-Binding/DataBindingtoGridViewC.htm [ ^ ]
http://msdn.microsoft.com/en-us/library/fkx0cy6d.aspx[^]



http://www.java2s.com/Tutorial/ASP.NET/0380__Data-Binding/DataBindingtoGridViewC.htm[^]


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

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