请教各位

解决方案 »

  1.   

    你把你的需求例子放出来啊,无非就是string的函数 substring/indexof  lastindexof等等函数搞定,再复杂的就是用正则就处理了
      

  2.   

    用gridview中的checkbox做批量删除,这是前台代码:
    <asp:TemplateField>
                        <HeaderTemplate>
                        <input ID="Checkbox1" type="checkbox" onclick="CheckAll(this)"  />全选
                        </HeaderTemplate>
                        <ItemTemplate><asp:CheckBox ID="cbDel" runat="server" />
                            <asp:HiddenField ID="hfsID" runat="server" value='<%#Eval("Id")%>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
    后台需要判断选中的id,如果选择两个id,
    for (int i = 0; i < this.GridView1.Rows.Count; i++)
                {
                    //查找单选框按钮  
                    CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbDel");
                    //隐藏控件,值为表的主键    
                    HiddenField hf = (HiddenField)GridView1.Rows[i].Cells[0].FindControl("hfsID");
                    //判断单选框是否被选择           
                    if (cb.Checked)
                    {
                        //主键之间用逗号隔开                       
                        ID = ID + hf.Value + " ";                }
                }
    红色部分为需要判断的id是否为最后一个,如果是需要把最后的“,”去掉
      

  3.   

    if(  ID.EndsWith(","))
      ID =  ID.Substring(0,  ID.Length-1);
      

  4.   

    也可以
    if( ID.EndsWith(","))
    ID=ID.TrimEnd(',');
      

  5.   

    for(i=0;i<length;i++)
    {
    if(i=0){}
    sb.Apend(lenght[i]);
    sb.Apend(",");
    }
      

  6.   

    if (cb.Checked)
      {
        if(Id.Length>0)
        {
            id +=("," + hf.Value);
        }
        else
            id+=hf.Value;
      }
      

  7.   

    if (cb.Checked)
    {
      //主键之间用逗号隔开   
      ID = ID + hf.Value + " "; }
    }
    ID = ID.TrimEnd(',');
    ...
      

  8.   

    if (cb.Checked)
      {
      //主键之间用逗号隔开   
      ID = ID + hf.Value + " "; }
      }
    ID=ID.Substring(0,ID.length - 1);
      

  9.   


    string a="a,b,c,d,";
    string b=a.Trim(',');
    b=a,b,c,d
      

  10.   

    for (int i = 0; i < this.GridView1.Rows.Count; i++)
      {
      //查找单选框按钮   
      CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("cbDel");
      //隐藏控件,值为表的主键   
      HiddenField hf = (HiddenField)GridView1.Rows[i].Cells[0].FindControl("hfsID");
      //判断单选框是否被选择   
      if (cb.Checked)
      {
      //主键之间用逗号隔开   
      ID = string.Format(ID + hf.Value + "{0}",i==this.GridView1.Rows.Count ? "" : ",";
     }
      }
      

  11.   

    KeyCode = KeyCode.Substring(0, KeyCode.Length - 1);去做好一位z
      

  12.   

    或者开始就用string.Join之类的方法,这样就不存在要删最后一个分隔符的问题了