Enable selection for a DataList in asp.net - asp.net

When we add a gridview we can enable selecting a row by checked enable selection on grid view proerty. But When we add DataList there is not 'enable selection' property for that.
Is any way to do this?
I want to bind a datalist with a table of my database and select a row to access row items or delete a row like gridview.
Please give me a sample codes .
Thanks alot.

http://www.codeproject.com/Articles/23559/Working-with-the-DataList-Control

Related

GridView with edit feature in ASP.net

How to create editable GridView like the one provided in the link below:
http://demo2.mixerp.org:8080/Sales/DirectSales.aspx
In this link, once, you select the item, corresponding details are filled. After that, if you click "Add" button, new row is created.
How is this done ?
You have to bind your data to grid view - refer link below..
http://www.dotnetfunda.com/articles/show/1619/how-to-perform-edit-update-and-delete-operation-in-gridview

Rebind gridview with updated row ASP.net

I have a gridview in ASP.nET and I have a "Select" command field. What I want to do is that when the user click on on the "select", I would like to take the selected row and do some calculations and rebind the original gridview with updated the row.
How can do this?
Thanks.
// do your thingy
DataGridViewName.DataBind();
There are a lot of places where grabbing the row is already explained. Take a look at this Link. You have to call the bind data method on the grid after your calculations. If you want to modify just that row, I would think you modify the source data collection for that row and rebind.
This link may also help. Instead of Edit, you could have Select.

Editing a row in a gridview

I have a two text boxes named region id and region name..and a button control
I enter some values into those text boxes and click the button to insert those values into the "gridview"and a "data table" associated with the gridview.
The gridview has the "enable editing" set to true..but when i click the "edit" button of a particular row in a gridview i get no response...i.e i do not get editable textboxes as it happens normally...
What is the solution for this?
You need to set the EditIndex of the row you are editting on the gdvMyGridView_RowEditing event:
gdvMyGridView.EditIndex = e.NewEditIndex
This will display your EditItemTemplate for the relevant row.
GridView Examples for ASP.NET 2.0: Editing the Underlying Data in a GridView
Editable GridView in ASP.NET 2.0
Edit control does not work out of blue. You have to write a backend SQL query for it to implement. The query will most likely look like this.
update regions SET name=#name where ID=#ID
where name and ID are fields of the table. Make sure the ID is the primary key, otherwise update will not work and you won't get any error.

Moving Selected rows Between Gridviews

I currently have Gridview1 which gets it's data from a database and displays a list of people.I also have a Gridview2 which is initially blank.
I would like to add the functionality of adding/removing rows to gridview2 from gridview1.
I've added a checkbox column to gridview1 to allow users to select the records they'd like to move. I've also added two buttons >> and <<.
Does anyone have an example of how i can add/remove selected records from Gridview1 to Gridview2?
thanks in advance!
Gridview2.rows.add(Gridview1.rows[INDEXTOMOVE]);

Can you set the value for the selecteddatakey of a gridview from codebehind?

Currently I am highlighting the rows on my gridview through code behind. The problem is when I inserted a new data through formview, I put the highlight on the new data but if you click edit or delete if would go for either the first data on the grid if you have not selected anything yet or the last data you have selected. Thanks.
According to the MSDN Documentation, GridView.SelectedDataKey its a read only property.
You may want to check the documentation for GridView.SelectedPersistedKey which is settable.

Resources