如题。

解决方案 »

  1.   

    这是解决超长字符串的代码,写在BindGridView()函数里 
    for (int i = 0; i <= GridView2.Rows.Count - 1; i++)
            {
                DataRowView mydrv;
                string gIntro;
                for (int j = 0; j < GridView2.Columns.Count - 2; j++)
                {
                    if (GridView2.PageIndex == 0)
                    {
                        mydrv = myds.Tables[0].DefaultView[i];
                        gIntro = Convert.ToString(mydrv[j]);
                        GridView2.Rows[i].Cells[j].Text = SubStr(gIntro, 4);
                    }
                    else
                    {
                        mydrv = myds.Tables[0].DefaultView[i + (20 * GridView2.PageIndex)];
                        gIntro = Convert.ToString(mydrv[j]);
                        GridView2.Rows[i].Cells[j].Text = SubStr(gIntro, 4);
                    }
                }
            }可以解决超长字符串问题,但是此时点击编辑按钮,编辑行不能出现TextBox按钮,无法编辑。
      

  2.   

    你问题的原因就是你在处理超长问题时将GridView的编辑模板弄没了。
    你要想别的办法处理,下面给你个建议:你要在GrivdView模板里操作,用三元运算节字符串。
      

  3.   

         a.Length>18?a.substring(0,17)+'...':a