Nevron Diagram
Skip Navigation Links
Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » ASP.NET 2.0 » Update data in other webpage
       
Author Reply
kundan mohanta
posted 11 posts
since Sep 03, 2011 
from

Update data in other webpage

  Posted on: 25 Dec 2011       
Dear all,


Suppose we insert some data in a webpage with textboxes, after inserting the data One column data will be shown as a link in a gridview along with other data in second page, So when I click that link data another webpage will be shown with their all data in textboxes.In that page update and cancel button available to do the respective actions. I need to update some data.


How to do this ? Please help.



Thanks in Advance
Satyapriya Nayak
posted  2231 posts
since  Mar 24, 2010 
from 

 Re: Update data in other webpage
  Posted on: 27 Dec 2011   Accepted Answer     0  
Hi Kundan,


Try this...

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Insert.aspx.vb" Inherits="Gridview_update_other_page_vb.Insert" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h2>Insert Employee Details</h2>
    <asp:Label ID="Label1" runat="server" Text="EmpName" Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:TextBox ID="txtFullName" runat="server"></asp:TextBox><br />
   
     <asp:Label ID="Label2" runat="server" Text="FName" Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:TextBox ID="txtFName" runat="server"></asp:TextBox><br />
   
     <asp:Label ID="Label3" runat="server" Text="LName" Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:TextBox ID="txtLName" runat="server"></asp:TextBox><br />
   
     <asp:Label ID="Label4" runat="server" Text="City" Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:TextBox ID="txtcity" runat="server"></asp:TextBox><br />
   
     <asp:Label ID="Label5" runat="server" Text="State" Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:TextBox ID="txtstate" runat="server"></asp:TextBox><br />
    <asp:Button ID="btn_insert" runat="server" Text="Insert Records"
        Font-Bold="True" onclick="btn_insert_Click" />
    </div>
    </form>
</body>
</html>


Imports System.Data
Imports System.Data.SqlClient
Partial Public Class Insert
    Inherits System.Web.UI.Page
    Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
    Dim con As New SqlConnection(strConnString)
    Dim str As String
    Dim com As SqlCommand
    Dim sqlda As SqlDataAdapter
    Dim ds As DataSet

    Protected Sub btn_insert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_insert.Click
        con.Open()
        str = "insert into employee(Empname,EmpFname,EmpLname,Empcity,Empstate) values('" & txtFullName.Text & "','" & txtFName.Text & "','" & txtLName.Text & "','" & txtcity.Text & "','" & txtstate.Text & "')"
        com = New SqlCommand(str, con)
        com.ExecuteNonQuery()
        con.Close()
        Response.Redirect("Default.aspx")
    End Sub
End Class



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Gridview_update_other_page_vb._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView runat="server" ID="GridView1"  AutoGenerateColumns="false"
            HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White"
            DataKeyNames="Empid" ForeColor="#663300" Font-Bold="True">
    <Columns>
    <asp:TemplateField HeaderText="Employee">
    <ItemTemplate>
    <a href ='<%#"Update.aspx?Empid=" & DataBinder.Eval(container.dataitem,("Empid")) %>'> <%#Eval("Empname")%>  </a>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Empname" HeaderText="EmpName" />
    <asp:BoundField DataField="EmpFname" HeaderText="EmpFname" />
    <asp:BoundField DataField="EmpLname" HeaderText="EmpLname" />
    <asp:BoundField DataField="Empcity" HeaderText="Empcity" />
    <asp:BoundField DataField="Empstate" HeaderText="Empstate" />
    </Columns>
          

<HeaderStyle BackColor="Red" ForeColor="White"></HeaderStyle>
            <AlternatingRowStyle ForeColor="#003300" />
          

    </asp:GridView>
    </div>
    </form>
</body>
</html>


Imports System.Data
Imports System.Data.SqlClient
Partial Public Class _Default
    Inherits System.Web.UI.Page
    Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
    Dim con As New SqlConnection(strConnString)
    Dim str As String
    Dim com As SqlCommand
    Dim sqlda As SqlDataAdapter
    Dim ds As DataSet
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            bind()
        End If
    End Sub
    Sub bind()
        con.Open()
        str = "select * from employee"
        com = New SqlCommand(str, con)
        sqlda = New SqlDataAdapter(com)
        con.Close()
        ds = New DataSet()
        sqlda.Fill(ds, "employee")
        GridView1.DataSource = ds
        GridView1.DataMember = "employee"
        GridView1.DataBind()
    End Sub

End Class



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Update.aspx.vb" Inherits="Gridview_update_other_page_vb.Update" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
    function Display(Empname)
    {
    alert(Empname + ':::updated successfully');
    if (alert)
    {
    window.location = 'Default.aspx';
    }
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
<tr>
<td colspan="2" align="center">
<b> Edit Employee Details</b>
</td>
</tr>
<tr>
<td>
EmpName:
</td>
<td>
<asp:Label ID="lblFullName" runat="server"/>
</td>
</tr>
<tr>
<td>
FName:
</td>
<td>
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
LName:
</td>
<td>
<asp:TextBox ID="txtLName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
<asp:TextBox ID="txtcity" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
<td>
State:
</td>
<td>
<asp:TextBox ID="txtstate" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpdate" runat="server" Text="Update" onclick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" onclick="btnCancel_Click"/>
</td>
</tr>
</table>

    </div>
    </form>
</body>
</html>



Imports System.Data
Imports System.Data.SqlClient
Partial Public Class Update
    Inherits System.Web.UI.Page
    Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
    Dim con As New SqlConnection(strConnString)
    Dim str As String
    Dim com As SqlCommand
    Dim sqlda As SqlDataAdapter
    Dim ds As DataSet
    Dim empid As Integer = 0
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        empid = Convert.ToInt32(Request.QueryString("Empid").ToString())
        If Not IsPostBack Then
            bind()
        End If
    End Sub
    Sub bind()
        con.Open()
        str = "select * from employee where Empid=" & empid
        com = New SqlCommand(str, con)
        sqlda = New SqlDataAdapter(com)
        com.ExecuteNonQuery()
        con.Close()
        ds = New DataSet()
        sqlda.Fill(ds)
        lblFullName.Text = ds.Tables(0).Rows(0)(1).ToString()
        txtFName.Text = ds.Tables(0).Rows(0)(2).ToString()
        txtLName.Text = ds.Tables(0).Rows(0)(3).ToString()
        txtcity.Text = ds.Tables(0).Rows(0)(4).ToString()
        txtstate.Text = ds.Tables(0).Rows(0)(5).ToString()
    End Sub

    Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
        con.Open()
        str = "update employee set EmpFname='" & txtFName.Text & "',EmpLname='" & txtLName.Text & "',Empcity='" & txtcity.Text & "',Empstate='" & txtstate.Text & "' where Empid=" & empid
        com = New SqlCommand(str, con)
        sqlda = New SqlDataAdapter(com)
        Dim result As Integer
        result = com.ExecuteNonQuery()
        con.Close()
        If result = 1 Then
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ShowSuccess", "javascript:Display('" & lblFullName.Text & "')", True)
        End If
    End Sub

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCancel.Click
        Response.Redirect("~/Default.aspx")
    End Sub
End Class





Thanks
If this post helps you mark it as answer
kundan mohanta
posted  11 posts
since  Sep 03, 2011 
from 

 Re: Update data in other webpage
  Posted on: 27 Dec 2011        0  
Many thanks satyapriya.I exactly wanted this to achieve.






       
Team Foundation Server Hosting
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved