actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows and columns in a datagrid if there are number of rows and columns.so in my web page i have got two labels two textboxes and three buttons namely add update and delete so when i click on the add button the data is added to datagrid and also displayed .....now i need the datagrid to function in such a manner that when i select a row it is selected in the datagrid(which has got only two columns of which one doesnt need to be updated as it being the primary key) and the data is automatically displayed in the textboxes and i can update it there and then when i click the update button it is updated in the datagrid........anybody please provide the code being a beginner i cant figure it out how to do it.....also if someone can provide the code to put a checkbox to select a particular row in datagrid and a search button to search anything in the datagrid it will be whole lot of help .........
i am pasting the present code
here my table name is CMRS_BUSINESSAREA_MASTER the column names are CBM_BUSAREA_CODE(which doesnt need to be updated) and CBM_BUSAREA_DESC
the datatype i am using is varchar2
the .net framework is 1.1 and visual studio.net 2003
Expand|Select|Wrap|Line Numbers
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- BindData();
- }
- OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
- DataSet ds = new DataSet();
- da.Fill(ds,"CMRS_BUSINESSAREA_MASTER");
- DataGrid1.DataSource = ds.Tables["CMRS_BUSINESSAREA_MASTER"].DefaultView ;
- DataGrid1.DataBind();
- }
- public void BindData()
- {
- OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
- DataSet ds = new DataSet();
- da.Fill(ds);
- DataGrid1.DataSource = ds.Tables[0].DefaultView ;
- DataGrid1.DataBind();
- }
- private void addbtn_Click(object sender, System.EventArgs e)
- {
- string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
- OleDbConnection con1 = new OleDbConnection();
- con1.ConnectionString = str;
- OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",con1);
- con1.Open();
- cmd.ExecuteNonQuery();
- con1.Close();
- BindData();
- }
- private void updtbtn_Click(object sender, System.EventArgs e)
- {
- }
- private void delbtn_Click(object sender, System.EventArgs e)
- {
- }
geetesh