Get culture from binded ObjectDataSource (C#)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Objectdatasource.aspx.cs"
    Inherits="Objectdatasource" %>

<script runat="server">
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        Culture = ddlCulture.SelectedValue;
    }

    void Page_PreRender()
    {
        lblDate.Text = DateTime.Now.ToString("D");
        lblPrice.Text = (512.33m).ToString("c");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Select Culture</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblCulture" Text="Culture:" AssociatedControlID="ddlCulture" runat="server" />
        <asp:DropDownList ID="ddlCulture" DataTextField="DisplayName" DataValueField="Name"
            DataSourceID="srcCultures" runat="server" />
        <asp:Button ID="btnSelect" Text="Select" runat="server" OnClick="btnSelect_Click" />
        <asp:ObjectDataSource ID="srcCultures" TypeName="System.Globalization.CultureInfo"
            SelectMethod="GetCultures" runat="server">
            <SelectParameters>
                <asp:Parameter Name="types" DefaultValue="SpecificCultures" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <hr />
        Today's date is:
        <br />
        <asp:Label ID="lblDate" runat="server" />
        <br />
        <br />
        The price of the product is:
        <br />
        <asp:Label ID="lblPrice" runat="server" />
    </div>
    </form>
</body>
</html>
Reactions

Post a Comment

0 Comments

Close Menu