Click here to Skip to main content
Sign Up to vote bad
good
See more: C#3.0
Hi,
I have created the form, in that added four buttons namely Add,Edit,Delete,Block.If i'm clicking the add button the add form is diplayed.If i'm clicking Edit button the empty form is displayed for me it should open the form with all details.The same process for edit,delete and block...
 
Regards
Balamurugan
Posted 4 Oct '12 - 0:53

Comments
bala1989 - 4 Oct '12 - 7:05
When i'm clicking the edit button it should bind all the values.For that i need coding...

2 solutions

you can write everything is same to edit,delete but the only changes in cmd line
 
In page load you have to reterive the data's from table.
SqlCommand cmd=new SqlCommand("select * from UserCreation");
and for edit something you need to update your database with cmd as
SqlCommand cmd=new SqlCommand("update UserCreation set columnname2= '"textbox2.Text'",columnname3='"textbox3.Text'" where columnname1= '"textbox1.Text'" ");
similarly for delete something you also need to delete from database with cmd as
SqlCommand cmd=new SqlCommand("delete from UserCreation where columnname1= '"textbox1.Text'" ");
This is simple model I think you may get some ideas.
  Permalink  
On click of Edit button its displyainng empthy form because page is post back .so on click of Edit button u should bind your data with controls .
  Permalink  
Comments
bala1989 - 4 Oct '12 - 7:05
When i'm clicking the edit button it should bind all the values.For that i need coding...
solanki.net - 4 Oct '12 - 7:14
can i show your code what r u writing on click of Add button ?
solanki.net - 4 Oct '12 - 7:32
k, Now on Edit button click event u should hit database for getting result(select * from tableName) and from front end u will have to send id(id of record that u want to edit ) .according to that id u will get datatable . then u can bind your controls with table columns.
bala1989 - 4 Oct '12 - 7:36
I can't get ur answer could u explain clearly...
bala1989 - 4 Oct '12 - 7:41
could u explain with the coding....
solanki.net - 4 Oct '12 - 7:59
same thing u will have to do . change here only SqlCommand cmd = new SqlCommand(" write query here for selecting data " ); sqlDataAdapter sda=new sqlDataAdapter (cmd); DataTable dt=new DataTable(); sda.fill(dt); then u can bind your controls ex: textbox1.Text= dt.Rows[0][0].ToString();
bala1989 - 4 Oct '12 - 7:23
Ya sure the code follows, private void button1_Click(object sender, EventArgs e) { try { string movies = ""; if (checkadmin.Checked) { movies = checkadmin.Text; } else if (checkuser.Checked) { movies = checkuser.Text; } string nam; DataminingProject.Class1 obj = new DataminingProject.Class1(); nam = obj.get(); SqlConnection con = new SqlConnection(nam); con = new SqlConnection("Data Source=NAREN;Initial Catalog=DataminingProject;User Id=sa; Pwd=saadmin"); con.Open(); SqlCommand cmd = new SqlCommand("Insert into UserCreations Values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + movies + "')", con); cmd.ExecuteNonQuery(); MessageBox.Show("User Created Successfully"); con.Close(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Marcus Kramer - 4 Oct '12 - 9:58
Please refrain from using textspeak in your answers. Use full words, please.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Mahesh Bailwal 353
1 Sergey Alexandrovich Kryukov 339
2 Maciej Los 290
3 CPallini 245
4 Rohan Leuva 175
0 Sergey Alexandrovich Kryukov 9,162
1 OriginalGriff 7,194
2 CPallini 3,923
3 Rohan Leuva 3,176
4 Maciej Los 2,633


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid