I will like to understand what exactly you want to do
with the GridView. Do you want to display in the GridView what the
user wants to save to the Database before committing it or after committing it to
the Database?
Anyway, if you want to save to the DB firstly before binding the table to the GridView, then you can try creating a Dataset
Firstly, assuming we have a connection to a Database, save what is in your textboxes by concatenation into the sql statement within a command object just like the one below.
The lines below will execute the SelectCommand below and bind the results to
a DataGridView.
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM titles;" ;
DataSet ds= new DataSet();
sqlDataAdapter1.Fill( ds ) ;
DataGridView1.DataSource=ds.Tables[0] ;
DataGridView1.Refresh();//Not really necessary. can remove this line.
Regards,
maleEngineer
hi, thanks for the suggestion but it didnt work. the table displays a list of students registered on the site. i'm using GRIDVIEW and not DATAVIEW as it failed me earlier.maybe the soln u suggested didnt work cos i placed it wrongly.
All the same, this are snippets of my code.
this is the code on the Gridview page:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=engineering; Integrated Security=True");
SqlCommand cmnd = new SqlCommand("SELECT * FROM test101",conn);
conn.Open();
GridView1.DataSource = cmnd.ExecuteReader();
GridView1.DataBind();
conn.Close();
the code on the login page is:
public void login1_Click(object sender, EventArgs e)
{
addstudentinfo.InsertParameters["Surname"].DefaultValue =
TextBox1.Text.ToString();
addstudentinfo.InsertParameters["Names"].DefaultValue =
TextBox2.Text.ToString();
addstudentinfo.InsertParameters["Regno"].DefaultValue =
TextBox3.Text.ToString();
can u still help? thanks