62,264
社区成员
发帖
与我相关
我的任务
分享if (!IsPostBack)
{
this.cgvTarTask.DataSource = T_KPI_Annual_TarTaskMaster.getKPI_tarTask(0);
this.cgvTarTask.DataBind();
CreateControls();
DDLBind(null);
InitWFField();
}
private void CreateControls()
{
foreach (GridViewRow e in cgvTarTask.Rows)
{
int intRow = e.Cells.Count;
for (int intI = 1; intI < intRow; intI++)
{
CustTextBox textbox = new CustTextBox();
textbox.ID = "txt" + e.RowIndex.ToString() + intI.ToString();
textbox.IsValRegular = true;
textbox.InputType = CustTextBox.textType.Int;
textbox.MaxLength = 3;
textbox.MaxValue = "100";
textbox.MinValue = "0";
if (e.Cells[intI].Text.Trim() == " ")
{
textbox.Text = "0";
}
else
{
if (IsNumberic(e.Cells[intI].Text.Trim()))
textbox.Text = Convert.ToString(double.Parse(e.Cells[intI].Text.Trim()) * 100);
else
textbox.Text = e.Cells[intI].Text.Trim();
}
textbox.Width = Unit.Pixel(80);
e.Cells[intI].HorizontalAlign = HorizontalAlign.Center;
e.Cells[intI].Controls.Add(textbox);
}
//第一行不显示
if (e.RowIndex == 0 || e.RowIndex == 1)
{
e.Visible = false;
}
}
} protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow r in GridView1.Rows)
{
for (int intI = 1; intI < r.Cells.Count; intI++)
{
TextBox textbox = r.FindControl("txt" + r.RowIndex.ToString() + intI.ToString()) as TextBox;
Response.Write(textbox.Text);
}
}
}//遍历控件
string temp = "";//保存获取到的所有textbox的值,值之间用逗号分隔
protected void SearchTxt(Control C)
{
ControlCollection CC;
if (C == null)
CC = Form.Controls;
else
CC = C.Controls;
for (int i = 0; i < CC.Count; i++)
{
if (CC[i].HasControls())//如果内部有控件,继续递归
StrStr += SearchTxt(CC[i]);
else if (CC[i].GetType() == typeof(TextBox))//如果发现textbox控件
{
temp += ((TextBox)CC[i]).Text+",";//获取textbox内容
}
else
continue;
}
}
if (!IsPostBack)
{
this.cgvTarTask.DataSource = T_KPI_Annual_TarTaskMaster.getKPI_tarTask(0);
this.cgvTarTask.DataBind();
}
CreateControls();
private void CreateControls()
{
foreach (GridViewRow e in cgvTarTask.Rows)
{
int intRow = e.Cells.Count;
for (int intI = 1; intI < intRow; intI++)
{
CustTextBox textbox = new CustTextBox();
textbox.ID = String.Format("textbox{0}{1}", e.RowIndex.ToString(), intI.ToString());
textbox.IsValRegular = true;
textbox.InputType = CustTextBox.textType.Int;
textbox.MaxLength = 3;
textbox.MaxValue = "100";
textbox.MinValue = "0";
if (e.Cells[intI].Text.Trim() == " ")
{
textbox.Text = "0";
}
else
{
if (IsNumberic(e.Cells[intI].Text.Trim()))
textbox.Text = Convert.ToString(double.Parse(e.Cells[intI].Text.Trim()) * 100);
else
textbox.Text = e.Cells[intI].Text.Trim();
}
textbox.Width = Unit.Pixel(80);
e.Cells[intI].HorizontalAlign = HorizontalAlign.Center;
e.Cells[intI].Controls.Add(textbox);
}
//第一行不显示
if (e.RowIndex == 0 || e.RowIndex == 1)
{
e.Visible = false;
}
}
}CustTextBox txtQUOTA = gvr.Cells[intI].FindControl("textbox" + gvr.RowIndex.ToString() + intI.ToString()) as CustTextBox;