你绑定也没关系。你定义一个转换的方法method然后在datagrid中一列取值
<%#method(databinder.val(dataitem,'fieldname'))%>
大概是这样,我手上没VS,没法测试

解决方案 »

  1.   

    在datagrid_onitemdatabound()事件中对该列进行操作
      

  2.   

    从整数到字符串和从字符串到整数的方法我都有了,就是用.net自带的方法实现的。具体怎么转换的我想可能知道或者不知道都无所谓。关键是如何在后建的那一列中把字符型的ip地址显示出来。
      

  3.   

    给个例子你分析一下
    public string GetCity(string Ip)
    {
    string ipCountry="";
    string ipCity="";
    string[] sip;
    sip = Ip.Split('.');
    long num=(Int64.Parse(sip[0])*256*256*256)+(Int64.Parse(sip[1])*256*256)+(Int64.Parse(sip[2])*256)+(Int64.Parse(sip[3]))-1;
    string Sql="select Top 1 country,city from Address where ip1 <="+num+" and ip2 >="+num;
    OleDbConnection myConnection = new OleDbConnection(Db.ConnectionString);
    OleDbDataAdapter myCommand = new OleDbDataAdapter(Sql, myConnection);
    DataSet DS = new DataSet();
    myCommand.Fill(DS, "Address");
    for (int i=0;i<DS.Tables["Address"].Rows.Count;i++)
    {
    ipCountry=DS.Tables["Address"].Rows[i][0].ToString();
    ipCity=DS.Tables["Address"].Rows[i][1].ToString();
    }
    DS.Clear();
    myCommand.Dispose();
    myConnection.Close();
    return ipCountry+ipCity;
    }
      

  4.   

    我知道在datagrid_onitemdatabound()事件中对该列进行操作
    我知道具体把整数ip地址到字符串地址和从字符串地址到整数地址的转换的方法但是,如何让我后添加的列显示字符串的ip地址呢?