在Html中可显示Value值代码如下:
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
System.IO.TextWriter tw = new System.IO.StringWriter(sb);
HtmlTextWriter OriginalStream = new HtmlTextWriter(tw);
base.Render(OriginalStream);
string s = sb.ToString();
int start = 0;
int end = s.Length;
if (this.RepeatColumns == 0 || this.RepeatColumns == 1)
{
for (int i = 0; i < this.Items.Count; i++)
{
end = s.Length;
start = s.IndexOf("<input", start, end - start);
StringBuilder sbItemAttribute = new StringBuilder();
this.Items[i].Attributes.Render(new HtmlTextWriter(new System.IO.StringWriter(sbItemAttribute)));
s = s.Insert(start + 7, sbItemAttribute.ToString() + " ");
if (!String.IsNullOrEmpty(this.Items[i].Value))
{
s = s.Insert(start + 7, "value=/"" + this.Items[i].Value + "/"");
}
start = s.IndexOf("/>", start, s.Length - start);
}
}
else//多列的处理
{
int arrcount = this.Items.Count;
int icol = this.RepeatColumns;
int icount = 1;
int irow = 0;
if (arrcount % icol > 0)
{
irow = (arrcount / icol) + 1;
}
else
{
irow = arrcount / icol;
}
for (int i = 0; i < irow; i++)
{
for (int j = i; j < arrcount; j = j + irow)
{
if (j >= arrcount || icount > icol)
{
break;
}
end = s.Length;
start = s.IndexOf("<input", start, end - start);
StringBuilder sbItemAttribute = new StringBuilder();
this.Items[j].Attributes.Render(new HtmlTextWriter(new System.IO.StringWriter(sbItemAttribute)));
s = s.Insert(start + 7, sbItemAttribute.ToString() + " ");
if (!String.IsNullOrEmpty(this.Items[j].Value))
{
s = s.Insert(start + 7, "value=/"" + this.Items[j].Value + "/"");
}
start = s.IndexOf("/>", start, s.Length - start);
icount++;
}
icount = 1;
}
}
writer.Write(s);
}