mvc cshtml 字符串操作
@using System.Text;
@{
int js = ;
string str="";
StringBuilder sb = new StringBuilder();
}
@foreach (var item in ViewBag.Doctypes)
{
if (item.DocTypeNo.Length == )
{
sb.AppendFormat("<optgroup label='{0}'>", item.DocTypeName); foreach (var item1 in ViewBag.Doctypes)
{
if (item1.DocTypeNo.Length < )//字符串小于6跳过
{
continue;
} if (item.DocTypeNo == item1.DocTypeNo.Substring(, )) //判断前5个是否相同
{
if (item1.DocTypeName == ViewBag.Current)
{
sb.AppendFormat("<option value='{0}' selected>{1}</option>", @item1.DocTypeName, @item1.DocTypeName);
//<option value="@item1.DocTypeName" selected>@item1.DocTypeName</option>
continue;
}
sb.AppendFormat("<option value='{0}'>{1}</option>", @item1.DocTypeName, @item1.DocTypeName); }
} sb.Append("</optgroup>" );
}
}
@Html.Raw(sb.ToString())
mvc cshtml 字符串操作的更多相关文章
- python学习笔记(字符串操作、字典操作、三级菜单实例)
字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...
- shell编程常用的截取字符串操作
1. 常用的字符串操作 1.1. 替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...
- php字符串操作集锦
web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...
- java 字符串操作和日期操作
一.字符串操作 创建字符串 String s2 = new String("Hello World"); String s1 = "Hello World"; ...
- [No000078]Python3 字符串操作
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...
- Python 字符串操作及string模块使用
python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...
- C语言字符串操作总结大全
1)字符串操作 strcpy(p, p1) 复制字符串 函数原型strncpy(p, p1, n) 复制指定长度字符串 函数原型strcat(p, p1) 附加字符串 函数原型strn ...
- c# 字符串操作
一.字符串操作 //字符串转数组 string mystring="this is a string" char[] mychars=mystring.ToCharArray(); ...
- C语言字符串操作总结大全(超详细)
本篇文章是对C语言字符串操作进行了详细的总结分析,需要的朋友参考下 1)字符串操作 strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat( ...
随机推荐
- String使用方式详细总结
1.用双引号创建 2.用new String方式创建 3.双引号相加创建 4.两个new String相加时 5.两个引用相加时 6.双引号加new String创建或者new String加双引号创 ...
- 【3】Django创建第一个项目
天地所以能长且久者,以其不自生,故能长生. --老子<道德经> 写在前面:Django在学习的过程中,我们会参考官方文档,从两部分进行讲解,第一部分主要是一个入门项目的搭建开发,第二部分是 ...
- git 强制pull
git fetch --all git reset --hard origin/master git pull
- 【高级算法】禁忌搜索算法解决3SAT问题(C++实现)
转载请注明出处:http://blog.csdn.net/zhoubin1992/article/details/46440389 近期梳理,翻出了当年高级算法课程做的题目.禁忌搜索算法解决3SAT问 ...
- 继续过Hard题目
接上一篇:http://www.cnblogs.com/charlesblc/p/6283064.html 继续过Hard模式的题目吧. # Title Editorial Acceptance ...
- HDU 4502
直接贪心就好. #include <iostream> #include <cstdio> #include <algorithm> #include <cs ...
- libyuv库的使用
libyuv是Google开源的实现各种YUV与RGB之间相互转换.旋转.缩放的库.它是跨平台的,可在Windows.Linux.Mac.Android等操作系统.x86.x64.arm架构上进行编译 ...
- LeetCode: Word Ladder [126]
[题目] Given two words (start and end), and a dictionary, find the length of shortest transformation s ...
- 三期_day06_登录和找回password
登录思路: 前台发送一个请求,然后通过spring的自己主动注參注入username和password,将password加密后与数据库中查找的做比較.返回是否通过. 这里还使用了EasyUI的校 ...
- POJ 1679 The Unique MST(推断最小生成树_Kruskal)
Description Given a connected undirected graph, tell if its minimum spanning tree is unique. Defini ...