My next problem was that I didn’t find the finished "bikes", so I decided to do something like a universal table editor in the database myself. There are, respectively, tables. They added a general, for editing. Introduced into it: the names of directories, lines select, insert, update, and Delte. Also included: the name of the tables in the database, the name of the identifying column of each table. I considered that I would need this data in the future. At the moment, I could only make the output of these tables with the following code:
protected void lb_catalogs_SelectedIndexChanged(object sender, EventArgs e) { string cmdsel = dv_editcatalog.Rows[2].Cells[1].Text; string cmdupd = dv_editcatalog.Rows[3].Cells[1].Text; string cmdins = dv_editcatalog.Rows[4].Cells[1].Text; string cmddel = dv_editcatalog.Rows[5].Cells[1].Text; SqlConnection sqlcon = new SqlConnection(conn); SqlCommand cmd_SQL = new SqlCommand(cmdsel, sqlcon); SqlDataAdapter da = new SqlDataAdapter(cmdsel, sqlcon); da.SelectCommand.CommandText = cmdsel; //da.UpdateCommand.CommandText = cmdupd; //da.InsertCommand.CommandText = cmdins; //da.DeleteCommand.CommandText = cmddel; DataSet ds = new DataSet(); da.Fill(ds, "TableAny"); GridView1.DataSource = ds.Tables["TableAny"]; this.DataBind(); }
On the page created hidden detailsview
, to get all the data about the selected directory. At first there was a program request to the database, but it was cumbersome, so I decided to simplify it for now. Data is loaded into the grid, buttons sel, upd, del are generated. Of these, only sel works. Help implement your plans. I don't know how to tie the remaining commands to the gridview. In addition to the select command, nothing else is assigned to writes:
"The object reference does not indicate an object instance."
Maybe you chose the wrong direction? Maybe it's better to manage the code with a datasource? I would be grateful for any help.