1——
把这个整数对100取模:
(C#)
200105%100或
(VB.Net)
200105 mod 1002——
看这个数据有点象日期型,如果是日期型,是否要取月份?那么使用(MM)格式化3——
把这个数字转换为字符串,然后取后两个字符:
string str="200105";
str=str.Substring(str.Length-2);

解决方案 »

  1.   

    谢了 我明白了str=str.Substring(str.Length-2);是取最后两位吗
    还有个问题在另一个贴没明白的
    请问怎么将datagrid的第一列显示从1,2,3一直这样排列下去啊?
    排名   分数
    1       100
    2        90
    3        80
    ……
    ……
    就是说 我的分数那一列已经排序了 只在第一列显示出序号就行 这个序号怎么显示出来 而且是递增的
      

  2.   

    序号
    http://community.csdn.net/Expert/topic/3308/3308927.xml?temp=.899151
      

  3.   

    datatable增加一列不就得了吗,这列随便你怎么赋值
      

  4.   

    select 排名=identity(int,1,1),* into #t from 表
    select * from #t
    drop table #t
      

  5.   

    把这个数字转换为字符串,然后取后两个字符:
    string str="200105";
    str=str.Substring(str.Length-2,str.Length);
      

  6.   

    string str = 200105;
    str= str.substring(str.length-2);
      

  7.   

    DataRow dr;
    int i;
    //自动添加空行
    if(rowCount<13)
    {
    for(i=1;i<=13-rowCount;i++)
    {
    dr=ds.Tables[0].NewRow();
    ds.Tables[0].Rows.Add(dr); 
    }
    } //自动添加序号
    for(i=1;i<=rowCount;i++)
    {
    dr=ds.Tables[0].Rows[i-1];
    dr[0]=i;
    } this.Datagrid1.DataSource=ds;
    this.Datagrid1.DataBind();
      

  8.   

    1.把这个数字转换为字符串,然后取后两个字符:
    string str="200105";
    str=str.Substring(str.Length-2);2.除100的模
      

  9.   

    关于序号的问题,这里给你个例子:<%@ Page language="C#"%>
    <script language="c#" runat=server>
    void Page_Load(object sender,EventArgs e)
    {
    System.Data.DataTable dt=new System.Data.DataTable();
    dt.Columns.Add("Score");
    System.Data.DataRow dr;
    for(int i=0;i<10;i++)
    {
    dr=dt.NewRow();
    dr["Score"]=100-i;
    dt.Rows.Add(dr);
    }
    DataGrid1.DataSource=dt;
    DataGrid1.DataBind();
    }
    void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
    Label lbl=e.Item.FindControl("Label1") as Label;
    if(lbl!=null)
    {
    lbl.Text=((int)(e.Item.ItemIndex+1)).ToString();
    }
    }
    </script>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML xmlns:pan="http://schemas.code6421.com/PowerAsp">
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
                          <asp:DataGrid runat=server id=DataGrid1 OnItemDataBound="DataGrid1_ItemDataBound">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:Label RunAt=server id=Label1/>
    <asp:Label RunAt=server id=Label2 Text='<%#DataBinder.Eval(Container,"DataItem.Score")%>'/>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    </form>
    </body>
    </HTML>
      

  10.   

    string str = 200105;
    str= str.substring(4,2);
    这样不可以吗
      

  11.   


    triout(笨牛)   详细,简洁
      

  12.   

    string strid = 200105;
    strid= strid.substring(4,2);
      

  13.   

    string str="200105";
    str=str.Substring(str.Length-2);