Showing posts with label dotnet. Show all posts
Showing posts with label dotnet. Show all posts

Wednesday, August 10, 2011

Nested Repeater in asp.net

No comments:


--Tables used.


CREATE TABLE [dbo].[user_types](
[ut_id] [int] IDENTITY(1,1) NOT NULL,
[ut_name] [varchar](50) NULL
)
------------------------
CREATE TABLE [dbo].[users](
[u_id] [int] IDENTITY(1,1) NOT NULL,
[u_ut_id] [int] NULL,
[u_name] [varchar](50) NULL,
[u_password] [varchar](50) NULL
)
-------------------------

Default.aspx

<body>
    <form id="form1" runat="server">
    <div>
    <%@ Import Namespace="System.Data" %>
        <h1 style="background-color:Lime;">Nested Repeater</h1>
        <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
                <h2 style="background-color:Aqua;" >Children of <%# DataBinder.Eval(Container.DataItem, "ut_name")%></h2>
                <asp:Repeater ID="Repeater2" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("typerelation") %>' runat="server">
                    <ItemTemplate>
                        <h3 style="background-color:Olive;">child item <%# DataBinder.Eval(Container.DataItem, "[\"u_name\"]")%></h3>
                    </ItemTemplate>
                </asp:Repeater>
            </ItemTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>

-----------------------------

Default.aspx.cs

using System.Data;
using System.Data.SqlClient;


protected void Page_Load(object sender, EventArgs e)
    {
        DataSet DsRep = new DataSet();
        SqlCommand SqlCmd = new SqlCommand();
        DataTable DtRep;
        string con = @"Server=.\SQLEXPRESS; Database=tutorials; uid=sa; pwd=asdf123*;";
        string command = "";


        command = "select ut_id,ut_name from user_types";
        DtRep = new DataTable();
        new SqlDataAdapter(command, con).Fill(DsRep, "parent");
     
        command = "select u_id,u_ut_id,u_name from users";
        DtRep=new DataTable();
        new SqlDataAdapter(command, con).Fill(DsRep, "child");


        DsRep.Relations.Add("typerelation", DsRep.Tables["parent"].Columns["ut_id"], DsRep.Tables["child"].Columns["u_ut_id"]);


        Repeater1.DataSource = DsRep.Tables[0];
        Page.DataBind();
    }

Sunday, July 17, 2011

windows in Ubuntu 11 as Virtual OS

No comments:

Running windows in Ubuntu 11 as Virtual OS.
Running Visual Studio 2010 Express and SQL Server Express Edition 2008 R2 in virtual OS
Google Chrome, FileZilla, and Virtual Box in Ubuntu.

Tuesday, December 21, 2010

asp.net and sql server

No comments:
aspx page

<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
   
    </div>
    <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList>
    <asp:Button ID="Button2" runat="server" onclick="Button2_Click"
        Text="Load all" />
    </form>
</body>

web.config

<appSettings>
        <add key="localhost" value="dbConnectionString"/>
    </appSettings>
    <connectionStrings>
        <add name="dbConnectionString" connectionString="Data Source=.\SQLEXPRESS; User ID=sa; Password=pswd; Database=testdatas; TimeOut=1 " providerName="System.Data.SqlClient"/>
    </connectionStrings>

aspx page.cs

public partial class _Default : System.Web.UI.Page
{
    SqlConnection sqlcon;
    SqlCommand SqlCmd;
    string ConnectionName = "";
    string ConnectionString = "";

    SqlDataReader SqlDr;
    List<string> LstString;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Response.Write(DateTime.Now.ToString());
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ConnectionName = ConfigurationManager.AppSettings["localhost"].ToString();
        ConnectionString = ConfigurationManager.ConnectionStrings[ConnectionName].ToString();
        sqlcon = new SqlConnection();
        SqlCmd = new SqlCommand();
        sqlcon.ConnectionString = ConnectionString;
        SqlCmd.CommandText = "insert into tbone (name) values (@users)";
        SqlCmd.Parameters.AddWithValue("@users",TextBox1.Text);
        SqlCmd.Connection = sqlcon;
        sqlcon.Open();
        SqlCmd.ExecuteNonQuery();
        sqlcon.Close();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        ConnectionName = ConfigurationManager.AppSettings["localhost"].ToString();
        ConnectionString = ConfigurationManager.ConnectionStrings[ConnectionName].ToString();
        sqlcon = new SqlConnection();
        SqlCmd = new SqlCommand();
        LstString = new List<string>();
        sqlcon.ConnectionString = ConnectionString;
        SqlCmd.CommandText = "select * from tbone";
        SqlCmd.Parameters.AddWithValue("@users", TextBox1.Text);
        SqlCmd.Connection = sqlcon;
        sqlcon.Open();

        SqlDr = SqlCmd.ExecuteReader();
        while (SqlDr.Read())
        {
            LstString.Add(SqlDr["name"].ToString());
        }
        SqlDr.Close();
        sqlcon.Close();

        DropDownList1.DataSource = LstString;
        DropDownList1.DataBind();
    }
}

Wednesday, August 18, 2010

GridView for listing download link

No comments:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" EnableModelValidation="True">
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="url_data_field" DataNavigateUrlFormatString="download_folder/{0}" 
            HeaderText="View" Text="Download" />
        </Columns>
    </asp:GridView>

Tuesday, May 25, 2010

Free download Ajax Control Toolkit

No comments:
Visit http://www.asp.net/ajax to get the download link..
Extract the downloaded file
Create a new Toolbox tab then click choose items and and pick AjaxControlToolkit.dll in the extracted folder.
Then click ok.

Calendar for asp.net TextBox control using ASP.NET AJAX Calendar Extender

No comments:
CalendarExtender is a asp.net ajax extender that can be used with any textbox. This provides a client side date picker.

Downlaod toolkit from http://ajaxcontroltoolkit.codeplex.com/

code:
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" TargetControlID="TextBox1">
        </asp:CalendarExtender>
    </div>
    </form>
</body>
  • In order to get a Calendar with an associated calendar icon image
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/images/cal.png" />
        <asp:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" TargetControlID="TextBox1" PopupButtonID="Image1">
        </asp:CalendarExtender>
    </div>
    </form>
</body>

Tuesday, April 7, 2009

Device Control Through PC - My First Post...

No comments:
In this project we can control household electrical or industrial appliances using a computer where there is a parallel port interface between the switching circuit and computer.
Jerome Jackson Rodrigues.
--Thank you.