1
Answer

asp.net and PHP websites shared service and data

Lawrence Pond

Lawrence Pond

10y
479
1
Hello Friends,

I have a SQL Server Tables and use Microsoft Tools (Visual Stuidio C# and ASP.Net) to develop web functionality. The data is processed and then business logic applied to transform results set. There is another group that I work with that  that uses php and they would like to use some of the data in there site as well.

I cannot give them direct access to the database but can provide a service they could call. I feel that WCF has more overhead  than we need but certainly is an option.

My Question is what are some other options that I could provide and what are the pro's and con's of each one with your preference.  What about WEB API can it be used by both asp.net and php? what are my limitations

Thanks in advance for your input.
Answers (1)
0
Abhishek Singh
NA 5.3k 1.1m 10y
Hi,

<asp:gridview ID="Gridview1" runat="server" AutoGenerateColumns="False" OnRowDataBound="Gridview1_RowDataBound" ShowFooter="True">
        <Columns>
            <asp:BoundField DataField="CustomerID" HeaderText="ID" />
            <asp:TemplateField HeaderText="Name">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("firstname") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("firstname") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
            <asp:Label ID="lbl" runat="server" Text="Total Amount" />
         </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Amount">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("amount") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("amount") %>'></asp:Label>
                </ItemTemplate>

                <FooterTemplate>
            <asp:Label ID="lblTotal" runat="server" />
         </FooterTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:gridview>
  

Code:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace gridViewTest
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        decimal total = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.populateData();
            }
        }

        public void populateData()
        {
            DataTable dt = new DataTable();


            dt.Columns.Add("CustomerID");
            dt.Columns.Add("FirstName");
         
            dt.Columns.Add("Amount");
            dt.Rows.Add("0001", "Abhishek", 10000);
            dt.Rows.Add("0002", "Ram", 20000);
            dt.Rows.Add("0003", "Alice", 30000);
            dt.Rows.Add("0004", "David", 40000);
           
            Gridview1.DataSource = dt;
            Gridview1.DataBind();

        }

        protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
        {

         
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                Label Amount = (Label)e.Row.FindControl("Label1");

                decimal Presents = Convert.ToDecimal(Amount.Text);
                total += Presents;

            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {

                Label lblTotal = (Label)e.Row.FindControl("lblTotal");

                lblTotal.Text = total.ToString();

            }



        }
    }
}

Hope this helps.
Accepted