我正在使用网站应用程序,在该网站中,我创建了下拉列表和文本框作为动态...该下拉列表包含费用列表...我在下拉列表中选择一种费用类型和在文本框中输入一些金额..然后我在Dropdownlist中再次选择一种类型的费用,并在文本框中输入一些金额...最后,我选择了一个文本命名为Dropdownlist中的总金额,它必须自动生成所有的总金额textboxes(beforeCreated)在文本框的末尾...计算动态生成的文本框中的总价值
我应该如何获得文本框结束的总价值.... 任何人请告诉我这个的解决方案.. 在此先感谢.. 。
我的代码: //这个函数用于创建将被添加动态生成的下拉列表和文本框
public void SetInitalRowFees()
{
DataTable dtFees = new DataTable();
DataRow drFees = null;
dtFees.Columns.Add(new DataColumn("Sno", typeof(string)));
dtFees.Columns.Add(new DataColumn("Column1", typeof(string)));
dtFees.Columns.Add(new DataColumn("Column2", typeof(string)));
drFees = dtFees.NewRow();
drFees["Sno"] = 1;
drFees["Column1"] = string.Empty;
drFees["Column2"] = string.Empty;
dtFees.Rows.Add(drFees);
//Store the DataTable in ViewState
ViewState["CurrentTableFees"] = dtFees;
// Session["CurrentTable"] = dt;
GrdFeesStructure.DataSource = dtFees.DefaultView;
GrdFeesStructure.DataBind();
}
//This function is used to add a new dropdownlist and textbox controls
public void AddFeesStructureGrid()
{
int rowIndex = 0;
if (ViewState["CurrentTableFees"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableFees"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
{
DropDownList box1 = (DropDownList)GrdFeesStructure.Rows[rowIndex].Cells[1].FindControl("ddlFeesDetails");
TextBox box2 = (TextBox)GrdFeesStructure.Rows[rowIndex].Cells[2].FindControl("txtAmount");
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["Sno"] = i + 1;
dtCurrentTable.Rows[i - 1]["Column1"] = box1.Text;
dtCurrentTable.Rows[i - 1]["Column2"] = box2.Text;
rowIndex++;
}
dtCurrentTable.Rows.Add(drCurrentRow);
ViewState["CurrentTableFees"] = dtCurrentTable;
GrdFeesStructure.DataSource = dtCurrentTable;
GrdFeesStructure.DataBind();
}
}
else
{
Response.Write("ViewState is null");
}
SetFeesStructureData();
}
现在我应如何做到这一点的网格?
我劝分配总对文本框输入做一些验证,如果用户输入'one'而不是1,或者除了数字之外还有其他内容? – 2010-02-24 08:24:09
@Tony:我想他只是在询问服务器端代码,他可能会早些时候验证他的页面,以便文本框只能有int类型的值。是不是在 – 2010-02-24 10:18:44