• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    Update a datagrid without Page Refresh

    Posted by on October 18, 2009 Leave a comment (25) Go to comments

    Introduction:
    This article will explain how to update datagrid values to database using AJAX without a page refresh.

    Main:
    Inserting Data to databases through front-end is a common task for all Web Developers.We Can do that without Page refresh through AJAX with the following simple steps.

    1.Forming Custom XML using front end Data’s.
    2.Posting the XML to ours Webapge.
    3.Reading the Incoming XML using RequestStream()
    4.Splitting the XML data and updating into database.

    In aspx page,
    <asp:datagrid id=SampleGrid runat=server AutoGenerateColumns=false>
    <Columns>
    <asp:TemplateColumn>
    <HeaderStyle width=10%></HeaderStyle>
    <ItemStyle width=10%></ItemStyle>
    <HeaderTemplate> StudentID </HeaderTemplate>
    <ItemTemplate>
    <span id="spnStudentID" style="Hand:Cursor;width:10;">
    <%#DataBinder.Eval(Container,"DataItem.StudentID") %> </span>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderStyle width=10%></HeaderStyle>
    <ItemStyle width=10%></ItemStyle>
    <HeaderTemplate> Name </HeaderTemplate>
    <ItemTemplate>
    <span id="spnName" style="Hand:Cursor;width:10;">
    <%#DataBinder.Eval(Container,"DataItem.Name") %> </span>
    <asp:TextBox id=txtName runat=server style="Display:none">
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderStyle width=10%></HeaderStyle>
    <ItemStyle width=10%></ItemStyle>
    <HeaderTemplate> Address </HeaderTemplate>
    <ItemTemplate>
    <span id="spnAddress" style="Hand:Cursor;width:10;">
    <%#DataBinder.Eval(Container,"DataItem.Address") %> </span>
    <asp:TextBox id=txtAddress runat=server style="Display:none">
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderStyle width=10%></HeaderStyle>
    <ItemStyle width=10%></ItemStyle>
    <HeaderTemplate> City </HeaderTemplate>
    <ItemTemplate>
    <span id="spnCity" style="Hand:Cursor;width:10;">
    <%#DataBinder.Eval(Container,"DataItem.City") %> </span>
    <asp:TextBox id=txtCity runat=server style="Display:none">
    <asp:button id=btnupdate runat=server style="Display:block" onclick="UpdateRow(this);">
    <asp:button id=btnSave runat=server style="Display:none" onclick="CallAjax(this);">
    </ItemTemplate>
    </asp:TemplateColumn>
    In Javascript,

    function UpdateRow(objbtn)
    {
    var row=objbtn.parentElement.
    var lblname = row.cells[1].cildNodes[0];
    var txtname = row.cells[1].cildNodes[1];
    var  lblAddress = row.cells[2].cildNodes[0];
    var txtAddress = row.cells[2].cildNodes[1];
    var lblCity = row.cells[3].cildNodes[0];
    var txtCity = row.cells[3].cildNodes[1];
    var btnSave = row.cells[3].cildNodes[3];
    lblname.Style.display='none';
    lblAddress.Style.display='none';
    lblCity.Style.display = 'none';
    txtname.Style.display='block';
    txtAddress.Style.display='block';
    txtCity.Style.display='block';
    btnSave.Style.display='block';
    objbtn.Style.display='none';
    }
    function CallAjax(this)
    {
    var row=objbtn.parentElement.
    var lblStudentID = row.cells[0].cildNodes[0];
    var lblname = row.cells[1].cildNodes[0];
    var txtname = row.cells[1].cildNodes[1];
    var  lblAddress = row.cells[2].cildNodes[0];
    var txtAddress = row.cells[2].cildNodes[1];
    var lblCity = row.cells[3].cildNodes[0];
    var txtCity = row.cells[3].cildNodes[1];
    var btnUpdate = row.cells[3].cildNodes[2];
    PassValues(lblStudentID.innerText,txtname.value,txtAddress.value,txtCity.value);
    lblname.Style.display='block';
    lblAddress.Style.display='block';
    lblCity.Style.display = 'block';
    txtname.Style.display='none';
    txtAddress.Style.display='none';
    txtCity.Style.display='none';
    btnUpdate.Style.display='block';
    objbtn.Style.display='none';
    }
    function PassValues(ID,name,Address,City)
    {
    var xml = '<?xml version="1.0"?><Body><Details><ID> '+ ID +' </ID><name>'+ name +' </name><Address> '+ Address +'</Address><City>'+ City +'</City></Details></Body>';
    var XMLHttpRequestObject = false;
    if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP")
    }
    XMLHttpRequestObject.open('POST",sampleUpdate.aspx);
    var response=XMLHttpRequestObject.send( xml);
    if(response.childNodes[0] != null)
    {
    alert(response);
    }
    }
    In CodeBehind,

    if(Request.InputStream != null)
    {
    XmlDocument doc = new XmlDocument
    doc.Load(Request.InputStream)
    string ID = doc.GetElementsByTagName("ID").InnerText;
    string name = doc.GetElementsByTagName("name").InnerText;
    string Addess = doc.GetElementsByTagName("Addess").InnerText;
    string City = doc.GetElementsByTagName("City").InnerText;
    str sql = "update Student_table set name = '" + name +"',Address = '" + Address +"' ,City ='" + City +"' where StudentsID ='" + ID "";
    try
    {
    using (SqlConnection connection = new SqlConnection(
    connectionString))
    {
    SqlCommand command = new SqlCommand(sql, connection);
    command.Connection.Open();
    command.ExecuteNonQuery();
    }
    }
    catch (param ex)
    {
    Response.Write (ex.ToString();
    }

    Conclusion:
    Hope this helps,
    Happy Coding.

    ASP.NET
    ← How to Download a Image from server using AJAX.
    How to Execute Server Side Method Using AJAX →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a comment

    25 Comments.

    1. Peter October 30, 2009 at 3:13 pm

      I cannot pass my webpage,i think i need to find current session id and need to add before the webpage,anybody help.

    2. Chris November 24, 2009 at 9:02 am

      Very Nice Article,and very useful

    3. brudo March 1, 2010 at 4:04 pm

      Its converted my app into a rich user experience.Thanks a lot.

    4. Elbert Kessner April 3, 2010 at 6:04 pm

      This is a very exciting post, I was looking for this knowledge. Just so you know I located your web site when I was doing research for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think.

    5. ?ivljenjsko Zavarovanje April 6, 2010 at 8:12 pm

      I really liked your blog! super

    6. Shelton Hissom April 19, 2010 at 10:58 pm

      I don’t agree with everything in this piece, but you do make some very good points. Im very interested in this matter and I myself do alot of research as well. Either way it was a well thoughtout and nice read so I figured I would leave you a comment. Feel free to check out my website sometime and let me know what you think.

    7. Tim Dorian April 20, 2010 at 6:51 pm

      Exceptional article, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. Im always looking for feedback.

    8. Janey Cham April 21, 2010 at 5:07 pm

      This is a superb write-up, I found your site looking around yahoo for a related theme and arrived to this. I couldnt come across to much different material on this piece, so it was great to discover this one. I likely will end up being returning to check out some other posts that you have another time.

    9. Judy Stasik April 22, 2010 at 4:35 pm

      This is a wonderful posting, I located your blog page doing research yahoo for a similar content and arrived to this. I couldnt come across to much additional information and facts on this posting, so it was wonderful to discover this one. I will probably end up being returning to check out some other articles that you have another time.

    10. Albertha Handeland April 22, 2010 at 11:18 pm

      This is a good summary, I was wondering if I could use this piece of writing on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away.

    11. Aaron Reome April 24, 2010 at 12:18 am

      Great piece of writing, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. I’m always looking for feedback.

    12. Emil Zamudio April 26, 2010 at 4:50 pm

      This is a good post, I was wondering if I could use this piece of content on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away.

    13. Jessie Sabedra May 3, 2010 at 11:26 pm

      I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites site list and will be checking back soon. Please check out my site as well and let me know what you think.

    14. choose golf clubs May 11, 2010 at 4:31 pm

      Very informative post. Thanks for taking the time to share your view with us.

    15. lcd tv reviews May 17, 2010 at 10:16 am

      I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

    16. Stanton Helzer May 20, 2010 at 7:37 pm

      This is a really good piece of content, I found your webpage looking around aol for a similar subject and came to this. I couldnt find to much other material on this post, so it was nice to find this one. I will likely end up being back again to look at some other articles that you have another time.

    17. homegym May 22, 2010 at 11:04 pm

      thanks!You made some good points there. I did a search on the topic and found most people will agree with your blog

    18. get back your ex June 9, 2010 at 6:34 pm

      Nice blog you have, the articles here are very helpful. Subscribed to RSS feed. Thanks! :D

    19. Kenneth Solarz June 11, 2010 at 9:06 pm

      This is a very exciting post, I was looking for this info. Just so you know I located your blog when I was browsing for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think.

    20. piece akumulacyjne July 7, 2010 at 6:48 pm

      Nice site and great text.

    21. Heriberto Fedder July 10, 2010 at 8:53 pm

      This is a superb post, but I was wondering how do I suscribe to the RSS feed?

    22. google adwords July 11, 2010 at 1:02 am

      Super text, I will add this blog to my favorites.

    23. Download music August 7, 2010 at 7:28 pm

      I thought it was going to be some boring old site, but I’m glad I visited. I will post a link to this site on my blog. I am sure my visitors will find that very useful.

    24. art deco May 3, 2011 at 2:33 am

      Apple now has Rhapsody as an app, which is a great start, but it is currently hampered by the inability to store locally on your iPod, and has a dismal 64kbps bit rate. If this changes, then it will somewhat negate this advantage for the Zune, but the 10 songs per month will still be a big plus in Zune Pass’ favor.

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Trackbacks and Pingbacks:

    • Datagrid Paging without Page Referesh | NetProgrammingHelp.com - Pingback on 2010/01/26/ 15:08

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top