GridView insert update delete in asp.net using objectdatasource - Part 24

preview_player
Показать описание

Link for text version of this video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

1. Compile your project.
3. Drag and drop ObjectDataSource control onto the webform.
4. Now configure ObjectDataSource control to use
GetAllEmployees() as "Select" Method
DeleteEmployee(int EmployeeId) as "Delete" method
UpdateEmployee(int EmployeeId, string Name, string Gender, string City) as "Update" method
InsertEmployee(string Name, string Gender, string City) as "Insert" method

Now change DataSourceID property of GridView1 control from "SqlDataSource1" to "ObjectDataSource1" and Save. You will get a message asking, if you want to "Refresh Fields and Keys for GridView1. Click No.

Finally in code-behind file change the implementation of "lbInsert_Click" as shown below.
protected void lbInsert_Click(object sender, EventArgs e)
{
ObjectDataSource1.InsertParameters["Name"].DefaultValue =
((TextBox)GridView1.FooterRow.FindControl("txtName")).Text;
ObjectDataSource1.InsertParameters["Gender"].DefaultValue =
((DropDownList)GridView1.FooterRow.FindControl("ddlInsertGender")).SelectedValue;
ObjectDataSource1.InsertParameters["City"].DefaultValue =
((TextBox)GridView1.FooterRow.FindControl("txtCity")).Text;
ObjectDataSource1.Insert();
}
Рекомендации по теме
Комментарии
Автор

have to admit... searched quite a bit online for tutorial and this is pretty good... really enjoyed them

SurendraDhanpaul
Автор

These are some great videos, thanks so much for making them! Job well done!

richceruolo
Автор

Very well done Kudvenkat. I was waiting for this video. Thanks allot for your effort to help the developers community.

Ayubajbnabi
Автор

Hi David, Thank you very much. It may take another week for GridView, and yes, we will be discussing about Repeater, DataList etc.

Csharp-video-tutorialsBlogspot
Автор

Hi Harika, thank you very much for the feedback. If you have liked the video, you can express it using the thumbs up button at the bottom of the video.

Csharp-video-tutorialsBlogspot
Автор

Thank you for creating this video, like your others its clear and simple to follow. Keep up the great work.

jfrmilner
Автор

Excellent sir, you are making big impact on .Net programmers

jeewanintube
Автор

thank you so much sir, very helpful tutorial.

solidlane
Автор

hi venkat,
ur videos are excellent....i am ur great follower....really ur videos are greately helpful for beginners....

harikaaakutota
Автор

Hi, thank you very much for taking time to give feedback.

Csharp-video-tutorialsBlogspot
Автор

I was wondering, is this procedure going to work for the multiple tables. Like if I have multiple tables and I want to update the attributes across the tables, is your update, insert going to work or you need to write store procedure for it. Otherwise its excellent tutorial. please reply.. Thanks

tusharupadhyay
Автор

very nice Kudvenkat, when grid view tutorials be finished?
are you gona make videos about other major data presentation like: repeater

davidespada
Автор

hi venkat sir create the form to show the saved data from the dtabase in a gridview with edit option.
When the user try to edit the perticular record, the selected record data will show in
a new form in a form with edit mode.
When in add mode the record will add and in the edit mode the record will update.
if u know answer plea3 tell me urgent

varikuti
Автор

will my sorting still work using this approach?

DHARMYOGCOM
Автор

if there are 15 or 20 columns in Employee table then is it like we have to loop through all the rows in mean we have to write 20 lines of codes in the while loop for retrieving the employee details....or is there any standard coding for that..please reply

Nitya
Автор

how is Delete method taking Employee id?? I am having trouble there. It is taking 0 .

roxxongaming
Автор

hi you r doing good job .. and thx a lot ..

i want to know how these method of insert update delete parameters recive the Mehod parameter means sequence of insert update and delete id Mehod parameter name how it intract with gridview contol when i click .. how thes parameters value pass to these method (means if i change the sequece or change the name wich doesn't match to table colum name what happen) can u plz explain reply plz

ayyappanganga
Автор

hi venkat, here u haven't used sqldataadapter....instead used
in ado.net part10 u said v can do all the operations using sqldataadapter....because sqldataadapter is disconnected data access model ....so i want to that procedure....pls post this video...i am eagerly for ur video....
GridView insert update delete in asp.net using objectdatasource - Part 24 in this video can i use datatable instead of list as u said sqldatareader video....

harikaaakutota
Автор

Get enough knowledge about DML implementation when we use difference sources

vasanthasankar
Автор

I really do enjoy your videos but this one has one flaw. If there are no rows you cant add a first one because the footer row wont show on empty data

jacqueswho