Edit and delete rows in gridview - c#

We know asp.net gridview can edit/delete by clicking the button along with the gridview bind with a database.
Can we do it in windows form? I mean how to customize the button event or borrow asp.net framework to winform?
Please see the image.

As far as I know the winform grid do not have these abilities, You'll have to create them explicitly, like add another column and implement his onlclick/doulbe click, it really have tons of events.
p.s. if u want the user to change values on the rows displayed you'll need this:
dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystroke

Related

Radio Boxes Clickable Images

I am trying to figure out how I would setup a group of images to work like radio buttons. Basically when a user clicks a image it wil display a check mark below to indicate it has been selected. I could accomplish showing the check mark I believe by a onclick event and some css. But what would be the best way to do this with ASP.net I also need to transmit the data to the server via a form.
I would populate a hidden field with the resulting value of the selection via client-side code. Then you just read that value in your code behind on submit.

Web application Listview question

In a list view in C# how can I make all the fields in a column editable at once? Right now I have the standard edit button which allows me to update just one line at a time. I want the end user to be able to click a button and allow then to edit the column in its entirety.
Rebind the ListView with all TextBoxes when the user clicks edit.
You would have to manually track if you're in edit mode or not and on postback loop through all the rows retrieving the values from the textboxes and store them.
There is no built-in functionallity for what you're trying to do but it's possible.

How to repeat textboxes and check box dynamically using repeaters

I have requirement in my application where I am struck . These is my scenario:
Initially I need to show up two text boxes with a check box and a button. upon clicking the button we need to generate one more row. Like wise we need to create multiple rows dynamically.
Initially I tried with Table Control but after struggling a lot, I came to know that we can create only one row dynamically using Table Control. So now I am planning to do in repeater control.
In this kind of scenario, it would be better to use the GridView Control Instead, take a look here some working examples:
http://www.revenmerchantservices.com/page/gridview-add-new-row.aspx
http://amitpatriwala.wordpress.com/2008/04/18/inserting-new-row-in-gridview-in-aspnet-20/

C#: Data Grid View Advanced Operations

I am developing a windows form application in C#. I have a datagridview on windows form.
This datagridview is poupulated dynamically, through some text file.
Now what i want to achieve the following functionaity
1) Normally, when user clicks on my datagridview then the respected cell is selceted i want to remove this functionality.i.e if user click anywhere on my datagridview then noting will happens
2) Along with this datagridview i also have a menu strip in my form, the second thing which i want to achieve is that when user click on a specific button (say B) then my mouse cursor changes to plus shape(+) and it allows user to draw a box on my datagridview. On the basis of which i later perform some calculation.
Since i am new to .net thats why i don't know how to acheive this. So reference to some tutorial will also work.
You first part of the question can be done by
dataGridView1.Enabled = false;
dataGridView1.CurrentCell = null;
Can you elaborate a bit more on the second
For the 1 problem you have said, write the following line of code in Selected index changed event grid.Selectedindex=-1;

Dynamically load user control

I have this GridView that have it's DataSource as a list of previously selected products.
For every item on it, I need to Eval it's ID and load a specifc form that the user must fill, then after that i've got to update the GridView.
I have made those specific forms as User Controls, is this the best approach for this scenario?
If yes, how can I dynamically load them, in a way that I can make queries/postbacks then update back my gridview?
What you want to develop is called Master/Detail view.
It is described for example in http://www.asp.net/data-access/tutorials/master-detail-using-a-selectable-master-gridview-with-a-details-detailview-cs .
The only difference that as Detail you need use FormView, where on some initialization event (like DataBound http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basedataboundcontrol.databound.aspx )you need to dynamically create you control and set its parent to current template of FormView

Categories