HOW TO ADD VIEW STAT DATA IN

Hirenmengar
Posted by Hirenmengar under ASP.NET category on | Points: 40 | Views : 1208
public partial class usercontrol_ViewState : System.Web.UI.UserControl
{
DataTable dt;
DataSet ds;
DataColumn dc;
static int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
dc = new DataColumn();
dt = new DataTable();
ds = new DataSet();
if (!IsPostBack)
{
ds.Tables.Add(dt);
dt.Columns.Add("Bill No.");
dt.Columns.Add("Bar Code");
dt.Columns.Add("IME No.");
dt.Columns.Add("Item Code");
dt.Columns.Add("Item Type");
dt.Columns.Add("Qty");
dt.Columns.Add("Rate");
dt.Columns.Add("Charge");
dt.Rows.Add();
dt.NewRow();
dg.DataSource = dt;
dg.DataBind();
ViewState["table"] = dt;
i = 0;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
dt = (DataTable)ViewState["table"];
dt.Rows[i][0] = TextBox1.Text;
dt.Rows[i]["Bar Code"] = TextBox2.Text;
dt.Rows[i]["IME No."] = TextBox3.Text;
dt.Rows[i]["Item Code"] = TextBox4.Text;
dt.Rows[i]["Item Type"] = TextBox5.Text;
dt.Rows[i]["Qty"] = TextBox6.Text;
dt.Rows[i]["Rate"] = TextBox7.Text;
dt.Rows[i]["Charge"] = TextBox8.Text;
dg.DataSource = dt;
dg.DataBind();
dt.Rows.Add();
dt.NewRow();
i++;

AND

Comments or Responses

Posted by: T.Saravanan on: 3/4/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Could you check your code again its working or not?

Kindly post your code inside the code tag.

Login to post response