4 Replies - 1862 Views - Last Post: 15 June 2011 - 12:11 AM Rate Topic: -----

#1 cutexxbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-June 11

how to insert record and delete data to/from datagridview

Posted 14 June 2011 - 07:37 PM

hihi
i doing a project regarding web service and window form application
what i have done is to retrieve the data to the datagridview by using the web service web method
however i am stuck with some of the problem
1. how am i going to do insert a record to the datagridview?
2. can i put delete button in each row so that user able to delete accordingly??
3. i able to do the update but how am i going to combine with the insert? so that if user insert an existing record, it can prompt them?
this is my retrieve and update code
public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Binds();   
           
        }
        protected void Bind()
        {
            WSRoll roll = new WSRoll();
            GVRoll.AutoGenerateColumns = false;
            GVRoll.DataSource = roll.getRoll().Tables[0];
        }

   

        private void btnUpdate_Click(object sender, EventArgs e)
        {

            WSRoll updater = new WSRoll();

            GVRoll.DataSource = updater.updateRoll(Convert.ToInt32(GVRoll.CurrentRow.Cells[0].Value), Convert.ToString(GVRoll.CurrentRow.Cells[1].Value), Convert.ToInt32(GVRoll.CurrentRow.Cells[2].Value));
            Bind();
        }





thanks in advance, hope to get some help soon

Is This A Good Question/Topic? 0
  • +

Replies To: how to insert record and delete data to/from datagridview

#2 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to insert record and delete data to/from datagridview

Posted 14 June 2011 - 08:06 PM

1. how am i going to do insert a record to the datagridview?
You can create it so that each time you add a record to your database, you also add an object (for example, Car) to a List<T>. Then when List<T> changes, update the DataGridView's .DataSource property.

2. can i put delete button in each row so that user able to delete accordingly??
Yes, you can. Look into the DataGridViewButtonColumn.

3. i able to do the update but how am i going to combine with the insert? so that if user insert an existing record, it can prompt them?
As to seeing if there are duplicate records, what criteria are you using for determining whether a record is a duplicate?
Was This Post Helpful? 0
  • +
  • -

#3 cutexxbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-June 11

Re: how to insert record and delete data to/from datagridview

Posted 14 June 2011 - 08:24 PM

View PostSergio Tapia, on 14 June 2011 - 08:06 PM, said:

1. how am i going to do insert a record to the datagridview?
You can create it so that each time you add a record to your database, you also add an object (for example, Car) to a List<T>. Then when List<T> changes, update the DataGridView's .DataSource property.

2. can i put delete button in each row so that user able to delete accordingly??
Yes, you can. Look into the DataGridViewButtonColumn.

3. i able to do the update but how am i going to combine with the insert? so that if user insert an existing record, it can prompt them?
As to seeing if there are duplicate records, what criteria are you using for determining whether a record is a duplicate?


hi
1. i don't want to dynamically add in from the back end code, i want the user to enter , may example enter in the textfield and then click on insert, what you say use the LIST<T> , i don't think this method web service can use right, cause basically i have a insert web method in the webs service, i need to call it, when don't know how and use what to call
2. using the DATAGRIDVIEWBUTTONCOLUMN, how can i code for that button ?
3.if the record is duplicate, user can a prompt message saying there is a similiar record, and ask them to enter again
Was This Post Helpful? 0
  • +
  • -

#4 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: how to insert record and delete data to/from datagridview

Posted 14 June 2011 - 10:13 PM

Quote

1. i don't want to dynamically add in from the back end code, i want the user to enter , may example enter in the textfield and then click on insert, what you say use the LIST<T> , i don't think this method web service can use right, cause basically i have a insert web method in the webs service, i need to call it, when don't know how and use what to call


I don't understand what you mean. Save information on demand (when user clicks), then load that information (that's on the client side still!) to a List<T>, then load that to the DataGridView. That's what I meant, sorry if it wasn't clear enough. :)

Quote

2. using the DATAGRIDVIEWBUTTONCOLUMN, how can i code for that button ?


There's a working example there. Did you follow it?

Quote

3.if the record is duplicate, user can a prompt message saying there is a similiar record, and ask them to enter again


I know that's what you meant. :) What criteria will make your program say, yep this is a duplicate. Is it just going to check the primary key?
Was This Post Helpful? 0
  • +
  • -

#5 cutexxbaby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 14-June 11

Re: how to insert record and delete data to/from datagridview

Posted 15 June 2011 - 12:11 AM

1. i may not have make clear to you
anyway, i was think of having some text field/box, and user key in and when click insert, the data will be refresh/updated to the datagridview, can it be possible?can show me the code of how this done?cause this is just what i thought

2. yes follow, bt still cant use it in my delete
3.check one of the datagridview field which is the rolldata, if the rolldata is same as the user key in, it will consider duplicated

This post has been edited by Curtis Rutland: 15 June 2011 - 06:47 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1