This is my technical area for troubleshooting and learning new programming skills and much more. Here, you will find answers on a wide range of technologies such as AI, Machine Learning, OpenAI, Databricks, ASP.NET, C#, Python, Microsoft Access, MySQL, Amazon Web Services, SQL Server, PL/SQL, JD Edwards, SAS, Salesforce, APIs, MVC, and many others. Please feel free to visit and join the discussion!
Tuesday, June 16, 2009
Monday, June 15, 2009
Gridview Template, Data-Binding in a Template asp.net
Gridview Template, Data-Binding in a Template asp.net
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" ReadOnly="true"/>
<asp:BoundField DataField="FirstName" HeaderText="First Name"/>
<asp:BoundField DataField="LastName" HeaderText="Last Name"/>
<asp:TemplateField HeaderText="Birth Date">
<ItemTemplate>
<asp:Label ID="BirthDateLabel" Runat="Server"
Text='<%# Eval("BirthDate", "{0:d}") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:Calendar ID="EditBirthDateCalendar" Runat="Server"
VisibleDate='<%# Eval("BirthDate") %>'
SelectedDate='<%# Bind("BirthDate") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField Text="Show Detail"
DataNavigateUrlFormatString="~/ShowEmployeeDetail.aspx?EmployeeID={0}"
DataNavigateUrlFields="EmployeeID" />
</Columns>
Source: http://msdn.microsoft.com/en-us/library/ms228046.aspx
Friday, June 12, 2009
RSS Feed, Affiliate Link Capture on Same Page - C#
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<script language = "C#" runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
for (int i = 0; i < 10; i++)
{
dr = dt.NewRow();
dr[0] = "Item " + i.ToString();
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
DataList1.DataSource = CreateDataSource();
DataList1.DataBind();
}
}
void Button_Click(Object sender, EventArgs e)
{
if (DataList1.Items.Count > 0)
{
Label1.Text = "The Items collection contains: <br />";
foreach(DataListItem item in DataList1.Items)
{
Label1.Text += ((DataBoundLiteralControl)item.Controls[0]).Text +
"<br />";
}
}
}
</script>
<head runat="server">
<title>DataList Items Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>DataList Items Example</h3>
<asp:DataList id="DataList1" runat="server"
BorderColor="black"
CellPadding="3"
Font-Names="Verdana"
Font-Size="8pt">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<HeaderTemplate>
Items
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "StringValue") %>
</ItemTemplate>
</asp:DataList>
<br /><br />
<asp:Button id="Button1"
Text="Display Contents of Items Collection"
OnClick="Button_Click"
runat="server"/>
<br /><br />
<asp:Label id="Label1"
runat="server"/>
</form>
</body>
</html>
Sourcse: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.items.aspx
Thursday, June 11, 2009
Wednesday, June 10, 2009
Redirect URL using 301 redirection for affiliate Marketing
Redirect URL using 301 redirection for affiliate Marketing
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", NEW_URL);
}
Method 2.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string sOldPath = HttpContext.Current.Request.Path.ToLower();
string sPage = "http://www.aspcode.net/articles/" + sOldPath;
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location",sPage);
Response.End();
}
Method 3.
protected override void OnInit(EventArgs e)
{
int i = Request.Url.ToString().IndexOf("www.");
if (i < 8 && i != -1)
{
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", Request.Url.ToString().Remove(i, 4));
Response.End();
}
base.OnInit (e);
}
Tuesday, June 9, 2009
Google Checkout Custom Control
Google recently introduce Google Checkout. "Google Checkout is a checkout process that you integrate with your website, enabling your customers to buy from you quickly and securely, using a single username and password. Once they do, you can use Google Checkout to charge their credit cards, process their orders, and receive payment in your bank account."
They currently have no ASP.NET examples posted on their site so I have created an ASP.NET 2.0 Custom Web Control that will allow you to easily integrated with their service by simply dropping a control on the page a specifying a few parameters. So here it is...
http://www.c-sharpcorner.com/UploadFile/jlf0002/googlecheckoutcustomcontrol08072006134735PM/googlecheckoutcustomcontrol.aspx