【发布时间】:2010-02-24 07:59:55
【问题描述】:
我正在使用网站应用程序,在该网站中,我动态创建了下拉列表和文本框...该下拉列表包含费用列表...我在下拉列表中选择一种费用类型并在文本框中输入一些金额..然后我在下拉列表中再次选择一种类型的费用并在文本框中输入一些金额...最后我在下拉列表中选择一个名为总金额的文本它必须自动生成所有文本框的总值(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();
}
现在我该怎么做?
【问题讨论】: