Monday, 22 October 2012

Fetch data from the database and place it in a marquee


1. First we should take the marquee tag in the source of our web form(Page.aspx) page like this:

<marquee direction="up" onmouseover="this.start()" onmouseout="this.stop()"
scrolldelay="300? style="height: 213px">
<
asp:Literal ID="lt1? runat="server"></asp:Literal></marquee>

Note:-> literal to show the database values in the marquee

2. In Database:

My Database Name: db2

Create a table:

create table news1
(

id
int identity(1,1),
headings varchar(50)
);

3. Page.aspx coding:

using System.Data.SqlClient;
SqlConnection conn1 = new SqlConnection("data source=AB\\SQLEXPRESS;initial catalog=db2;integrated security=true");
SqlDataAdapter da1 = new SqlDataAdapter("select * from news1?, conn1);
DataSet ds1 =
new DataSet();
da1.Fill(ds1, "news1?);
string s1;
s1 = "<table><tr><td><a href=Default3.aspx style=font-family: fantasy; font-size: small; font-weight:bold; font-style: normal; color: #660066>";

s1 += ds1.Tables[
"news1"].Rows[0][1].ToString();
s1 += "</a></td>";
s1 += "<br/>";
s1 += "<tr><td><a href=Default2.aspx style=color: #9966FF; font-weight: bold;>";
s1 += ds1.Tables[
"news1"].Rows[1][1].ToString();
s1 += "</a></td></table>";
lt1.Text = s1.ToString();

1. First we should take the marquee tag in the source of our web form(Page.aspx) page like this:

<marquee direction="up" onmouseover="this.start()" onmouseout="this.stop()"
scrolldelay="300? style="height: 213px">
<
asp:Literal ID="lt1? runat="server"></asp:Literal></marquee>

Note:-> literal to show the database values in the marquee

2. In Database:

My Database Name: db2

Create a table:

create table news1
(

id
int identity(1,1),
headings varchar(50)
);

3. Page.aspx coding:

using System.Data.SqlClient;
SqlConnection conn1 = new SqlConnection("data source=AB\\SQLEXPRESS;initial catalog=db2;integrated security=true");
SqlDataAdapter da1 = new SqlDataAdapter("select * from news1?, conn1);
DataSet ds1 =
new DataSet();
da1.Fill(ds1, "news1?);
string s1;
s1 = "<table><tr><td><a href=Default3.aspx style=font-family: fantasy; font-size: small; font-weight:bold; font-style: normal; color: #660066>";

s1 += ds1.Tables[
"news1"].Rows[0][1].ToString();
s1 += "</a></td>";
s1 += "<br/>";
s1 += "<tr><td><a href=Default2.aspx style=color: #9966FF; font-weight: bold;>";
s1 += ds1.Tables[
"news1"].Rows[1][1].ToString();
s1 += "</a></td></table>";
lt1.Text = s1.ToString();

Sunday, 21 October 2012

Save Data Using Excel File



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

<!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">

<asp:GridView ID="gridviewXMLInsertEditDelete" runat="server"
AutoGenerateColumns="False" ShowFooter="True"
onRowCancelingEdit="gridviewXMLInsertEditDelete_RowCancelingEdit"
onRowDeleting="gridviewXMLInsertEditDelete_RowDeleting"
onRowEditing="gridviewXMLInsertEditDelete_RowEditing"
onRowUpdating="gridviewXMLInsertEditDelete_RowUpdating"
onRowCommand="gridviewXMLInsertEditDelete_RowCommand" CellPadding="4"
    ForeColor="Black" BackColor="#CCCCCC" BorderColor="#999999"
    BorderStyle="Solid" BorderWidth="3px" CellSpacing="2" Height="329px"
    Width="687px"     >
    <FooterStyle BackColor="#CCCCCC" />
    <RowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowEditButton="true" />
<asp:CommandField ShowDeleteButton="true" />
<asp:TemplateField HeaderText="First Name">
<ItemTemplate>
<asp:Label ID="lblFname" runat="server"
           Text='<%#Eval("FirstName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFirstName" runat="server"
             Text='<%#Bind("FirstName") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsert" runat="server"
            Text="Insert" CommandName="InsertXMLData"/>
<asp:TextBox ID="txtFirstNameInsert" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Last Name">
<ItemTemplate>
<asp:Label ID="lblLname" runat="server"
           Text='<%#Eval("LastName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLastName" runat="server"
             Text='<%#Bind("LastName") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLastNameInsert" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="lblLocation" runat="server"
           Text='<%#Eval("Location") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLocation" runat="server"
             Text='<%#Bind("Location") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLocationInsert" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
    <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White"  />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>

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