Hello, I am trying to create a program where the user enters in information, and it gets stored to the dataset, and in turn it gets binded to the datagrid so that it shows up. I am not using a database at all in this project. Here's what my code looks like, my data grid never shows up.
Code:protected System.Data.DataSet dataSet1 = new DataSet(); protected System.Web.UI.WebControls.DataGrid DataGrid1; protected System.Web.UI.WebControls.Label UserLabel; protected System.Data.DataTable dataTable1 = new DataTable("Users"); int count=0; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here count++; if(count==1) { dataTable1.Columns.Add("User_Name"); dataTable1.Columns.Add("Passwords"); } string str = ""; string str2 = ""; View_Panel.Visible=false; if(IsPostBack) { Edit_Panel.Visible=false; str = Request.Form["UserText"]; // get User Text from form str2 = Request.Form["PassText"]; // get the password from the form View_Panel.Visible=true; UserView.Text = str; PassView.Text = str2; dataSet1.Tables.Add(dataTable1); // add datatable to dataset DataRow row1 = dataTable1.NewRow(); // create new row in table row1["User_Name"] = str; // store User Text into User Name row1["Passwords"] = str2; // store Pass Text into Passwords dataTable1.Rows.Add(row1); // add row to the datatable dataSet1.AcceptChanges(); DataGrid1.DataSource = dataSet1.DefaultViewManager;// bind dataset to datagrid DataGrid1.Visible=true; } }



LinkBack URL
About LinkBacks


