Display, Edit , Update and delete data using DataList
in Asp.Net and C#
DataList control is a data bound control which display repeated list of item of database.Manupulation of data in DataList is possible. We can edit and delete data in DataList. DataList control can be bound with database tables, xml file or other list of item (Array,ArrayList,Collections,Hash Table etc.).
Unlike GridView ,DataList does not have any default template to display data. So Developers has to use templates like ItemTemplate or EditItemTemplate to display data in DataList control.
DataList support some command name for button control for the manupulation of data.
DataList Support following command name- Edit—call edit item event of DataList Update—call update item event of DataList Delete—call item deleted event of DataList Cancel – call cancel edit event of DataList.
You can also give your own command name in DataList.
Here I am giving an example of how we can display ,edit , update and delete data using DataList control of Asp.Net.
DataList uses templates to display ,edit and update data. Common templates are given below:
ItemTemplate- Item Template define how to display data in DataList control EditItemTemplate-- Edit Item Template define how to display data for editing
I have used followin database table in my example. Use following script to create table in your sql server databae Use following code in your .aspx page Write followin code in your page_load event Following method will bind DataList to database Below is edit event of grid view which will fire when user click on edit button Now here is update event which will fire when user click on update button Below is canceling event, fire when user click on cancel button with command name cancel
Other Related Posts
no fear choudhary is here,Tuesday, July 13, 2010
Comments :
14
comments to “Display,Edit ,Update and delete data using DataList in Asp.Net”
Very good article, I am new in datalist control and understand all the events of datalist control, I am very thanks full to you to write this article..................
yash choudhary
this is very use full code for data list
thnx for this tutorial it helped me a lot...
good post
Awesome! Thank you so much! Your post really helped me..^_^
good work chaudhary..... it helps me alot, thanku very much...
delete code kha hai edit insert update mast hai...!@
Nice article.....it helped me alot
but delete command is not here declare.
please detail.
Very good article, I am new in datalist control and understand all the events of datalist control, I am very thanks full to you to write this article..................
Great Article. I am new to ASP.Net was having trouble in datalist control, this Article helped me a lot. Thank You very much.
Can I do Same Task Through SqlDataSource not Coding
I Really appreciate this efforts.
Nice and slick