dataGridView上的数据不可见 [英] Data on dataGridView not visible

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

问题描述

即使单元格上存在数据,dataGridView也不会在每个单元格上显示值...这些值仅在具有当前焦点的单元格上可见...但是在cellclick上它不设置为可见

The dataGridView is not displaying the values on each cell even though data is present on the cells...The values are visible only on cell which is having the current focus...But its not set to be visible on cellclick

推荐答案

可以使用以下代码创建示例Gridview:
A sample Gridview can be created with the following code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
        <Columns>
            <asp:BoundField DataField="country" HeaderText="Country" ReadOnly="True" SortExpression="country" />
        </Columns>
    </asp:GridView>



在page_load事件中使用以下代码



The following code is used in the page_load event

string sql = "Select * from countries Order By Country";
        SqlDataAdapter da = new SqlDataAdapter(sql, "Data Source=SSSLT71\\SQLEXPRESS08;Initial Catalog=Test;User ID=sa; password=123456");
        DataTable dt = new DataTable();
        da.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();



希望对您有帮助



Hope this will help you


尝试一下...

try this...

private void get_datagridview_details()
{
    try
    {
       DataSet ds = new DataSet();
       //use your function on there
       // ds = gBL.Show_datagridview_Details();
        gv_party_datagridview1.DataSource = ds.Tables[0];
        datagridview1.readonly=true;
    }
    catch (Exception ex)
    {
       Messagebox.show(ex.message);
    }
}


这篇关于dataGridView上的数据不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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