Click here to Skip to main content
12,550,545 members (42,423 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#3.0 C#
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...

Posted 4-Oct-12 0:53am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 .
Comments 4-Oct-12 7:14am
can i show your code what r u writing on click of Add button ? 4-Oct-12 7:32am
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. 4-Oct-12 7:59am
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();
then u can bind your controls
ex: textbox1.Text= dt.Rows[0][0].ToString();
Marcus Kramer 4-Oct-12 9:58am
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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100