Hi frndz!
i am doing project in asp.net4.0,c#. In my project i am using listview . In listview adding a dynamic rows. The first row inserted successfully. when iam trying to add second row it inserted successfully but the first row will be(when postback occurs) cleared,so for that problem i can use the viewstate property. the problem will be solved. At the same time one or more users adding rows to listview the values are clashed.
Below is my code :
In ADD button click
table = (DataTable)ViewState["table1"];
table.Columns.Add("Gold",
typeof(string));
table.Columns.Add("Purity",
typeof(string));
table.Columns.Add("Agold", typeof(string));
dr =
table.NewRow();
dr["Gold"] = TxtGold.Text;
dr["Purity"] =
TxtPurity.Text;
dr["Agold"] = TxtAgold.Text;
table.Rows.Add(dr);
int
count = table.Rows.Count;
TotGold = 0.0;
TotAgold =0.0;
for (int i = 0;
i < count; i++)
{
TotGold = TotGold +
Convert.ToDouble(table.Rows[i]["Gold"].ToString());
TotAgold = TotAgold +
Convert.ToDouble(table.Rows[i]["Agold"].ToString());
}
ListView2.DataSource
= table;
ListView2.DataBind();
ViewState["table1"] = table;
Here is we adding a row dynamically in listview
Iam in urgent need to complete help me frndz. Thanks in advance!