1。如何控制列宽?就是如果数据超过宽度,就显示前面部分,然后鼠标指上去提示出完整的内容。2。我的表里其中有3项:中文名,英文名,国别(中/外)。DataGrid中用一列“名称”来显示中文名或英文名,显示哪一个是根据国别字段来判断的。请问能不能实现?

解决方案 »

  1.   

    参考相关信息
    http://singlepine.cnblogs.com/articles/309354.html
    http://singlepine.cnblogs.com/articles/266538.html
    http://singlepine.cnblogs.com/articles/289156.html问题二最直接的就是用一个存储过程
    create procedure getcountry
    (
     @type varchar(2)
    )
    as
    beginif @type='中'
    select 中文名 as 名称 from tbl
    else
    select 英文名 as 名称 from tbl
    end 
    go--exec getcountry '外'
      

  2.   

    private void Datagrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if((e.Item.ItemType == ListItemType.Item) ||
    (e.Item.ItemType == ListItemType.AlternatingItem))
    { string s;
    string t=e.Item.Cells[1].Text;//Cell[1]国别所在的cell
    if(t.Trim()=="1")
    {
    e.Item.Cells[2].Text = "中文名";//Cell[2]名称所在的cell
    }
    else
    {
    e.Item.Cells[2].Text = "英文名";
    } }
    }

    }