现在想 每次 都取 这些数据的 第一个数据 该如何写 程序 "1,11,111/2,22,222/3,33,333" 提前谢谢啦
解决方案 »
- F5刷新时,提示不重新发送信息将无法刷新网页...
- 在ajax js盛行的时代 asp.net 控件开发 有必要吗【200分讨论哈】
- dwz 搜索分页问题
- 提示:HTTP500错误
- ajax.dll ajaxPro.dll 是微软发布的吗? 如果不是那是谁发布的?我发现这个问题没人知道啊!!
- 如何把Excel表单形式的数据填好后存入数据库?
- 推荐一个功能很不错的日期时间选择控件,Webcombox控件
- word文件不直接打开,先下载到客户端
- (新手求助)FCKdetail 与 detailsview 编辑时点击更新会自动变成插入模式
- 如何点击页面上的一个链接激活客户端邮件工具(outlook等等)
- IIS内浏览我自己建的网站出错,求助啊~~~~~
- Forms认证 登陆状态丢失的原因
string str = "1,11,111/2,22,222/3,33,333";
string str1 = str.Split('/')[0];
string[] array ="1,11,111/2,22,222/3,33,333".Split(new char[] {'/'},StringSplitOptions.RemoveEmptyEntries);
array[0]也就是1,11,111
string[] str1 = str.Split('/');
for(int i=0;i<str1.length;i++){
具体输出的值的格式如
1 2 3
11 22 33
111 222 333
这里可以输出你要的格式。
}
1,11,111
2,22,222
3,33,333
正确的应该是:
string str = "1,11,111/2,22,222/3,33,333";
string[] sum = str.Split('/');
string[] str1 = sum[0].Split(',');
string[] str2 = sum[0].Split(',');
string[] str3 = sum[0].Split(',');
for(int i=0;i<str1.length;i++)
{
str1[i] + str2[i] + str3[i]
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type ="text/css">
td{ border :#e7e7e7 1px solid;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID ="gvTs" runat ="server" AutoGenerateColumns="false" GridLines="Both"
>
<Columns >
<asp:TemplateField>
<ItemTemplate>
<table style ="border :#e7e7e7 1px solid;" >
<tr><td>用户名</td><td colspan="2"><asp:TextBox ID ="txtName" runat ="server" Text ='<%#Eval("Name") %>'></asp:TextBox></td></tr>
<tr>
<td>
编号
</td>
<td>
尺码
</td>
<td>
颜色
</td>
</tr>
<tr>
<td><%=No %></td>
<td><%=Size %></td>
<td><%=Colors %></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
public partial class Default2 : System.Web.UI.Page
{
private string str = @"Data Source=DEEPXP\SQLEXPRESS;Initial Catalog=test1;User ID=sa; pwd=123";
protected string No;
protected string Size;
protected string Colors;
private int count;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvTs.RowDataBound += gvTs_RowDataBound;
gvTs.DataSource = getTs();
gvTs.DataBind(); count = 1;
} }
public List<Test> getTs()
{
string sql = string.Format("select * from ts");
SqlConnection conn = new SqlConnection(str);
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
List<Test> list = new List<Test>();
if (dr.HasRows)
{
while (dr.Read())
{
Test ts = new Test();
ts.Name = dr["Name"].ToString();
ts.Content = dr["Content"].ToString();
list.Add(ts);
} dr.Close();
}
conn.Close();
return list;
}
protected void gvTs_RowDataBound(object sender, GridViewRowEventArgs e)
{ if (e.Row.RowType == DataControlRowType.DataRow)
{
Test ts = (Test)e.Row.DataItem;
string content = ts.Content;
//"1,11,111/2,22,222/3,33,333" string[] str = content.Split('/');
string[] a = new string[3];
string[] b = new string[3];
string[] c = new string[3];
for (int i = 0; i < 3; i++)
{
if (i == 0)
{
a = content.Split('/')[i].Split (','); }
if (i == 1)
{
b = content.Split('/')[i].Split(',');
}
if (i == 2)
{
c = content.Split('/')[i].Split(',');
}
}
for (int i = 0; i < 3; i++)
{
if (i == 0)
{
No = a[i];
Size = b[i];
Colors = c[i]; }
if (i == 1)
{
No = a[i];
Size = b[i];
Colors = c[i];
}
if (i == 2)
{
No = a[i];
Size = b[i];
Colors = c[i];
}
}
}
}
}
public class Test
{
private string name; public string Name
{
get { return name; }
set { name = value; }
}
private string content; public string Content
{
get { return content; }
set { content = value; }
}
}
输出的值为
用户名
编号 尺码 颜色
aaa bbb ccc
用户名
编号 尺码 颜色
aaa bbb ccc
实际我想要输入的为
用户名
编号 尺码 颜色
1 2 3
11 22 33
111 222 333
用户名
编号 尺码 颜色
a b c
aa bb cc
aaa bbb ccc 请教 哪里有问题
string[] str1 = str.Split('/');
string[,] str3=new string[3,3];
string[] str2;
StringBuilder label = new StringBuilder();
for (int i = 0; i < str1.Length; i++)
{
str2= str1[i].Split(',');
for (int j = 0; j < str2.Length; j++)
{
str3[i, j] = str2[j]; //先保存到二维数组
}
}
for (int j = 0; j < 3; j++)
{
for (int i = 0; i < 3; i++)
{
label.Append(str3[i,j] + " "); //行和列倒过来
}
label.Append("\r");
}
label1.Text = label.ToString();
1 2 3
11 22 33
111 222 333 现在绑定的仅仅是最后一条信息 请指教