Monday, 7 January 2013
How to show image in grideview from database Sql server
How to show image
in grideview from database Sql server
User InterPage from eassy2connect.com
<body>
<form id="form1" runat="server">
<div id="wrapper">
<div id="header" class="container">
<div id="logo">
<h1><a href="#">e<span class="style8">@</span>ssy2connect</a></h1>
<p>Simply Connect</p>
</div>
<div id="menu">
<ul>
<li class="current_page_item"><a href="NewRegistert.aspx">Post&Ad</a></li>
<li><a href="UcontactUs.aspx">ContactUs</a></li>
<li><a href="Logout.aspx">logOut</a></li>
<li><a href="UserMasterpage.aspx">Home</a></li>
<%--<li><a href="#">
<img src="New%20folder/facebookblack.png" style="width: 42px; height: 25px" />
</a></li>--%>
</ul>
</div>
</div>
<!-- end #header -->
<div id="page">
<div id="content">
<div width: 890px"><table style="width: 100%;">
<tr bgcolor="#B9B9B9">
<td>
<asp:Button ID="Button1" runat="server" BackColor="#B9B9B9" BorderStyle="None"
Font-Bold="True" ForeColor="Black" Height="62px" onclick="Button1_Click"
Text="ManageMyAd" Width="195px" />
<asp:Button ID="Button2" runat="server" BackColor="#B9B9B9" BorderStyle="None"
Font-Bold="True" ForeColor="Black" Height="62px" onclick="Button2_Click"
Text="MyDetails" Width="192px" />
<asp:Button ID="Button8" runat="server" onclick="Button8_Click"
Text="eassy2connect Fun" Font-Bold="True" Height="52px" Width="171px" />
</td>
</tr>
</table></div>
<asp:Panel ID="Panel1" runat="server" style="height: 100%; width: 890px">
<div style="height: 70px; width: 890px">
<table style="height: 65px"><tr><td class="style15" align="center"><b><span class="style16">
Hello</span></b>
<asp:Label ID="Label7" runat="server" Font-Bold="True" ForeColor="#CC0000"
style="font-size: xx-large" Text="Label" Font-Names="Castellar"></asp:Label>
</td><td class="style14">Welcome To e@ssy2connect</td></tr></table>
</div>
<div style="height: 66px; width: 890px" align="center">
<table style="width: 100%; height: 65px;" align="center">
<tr>
<td align="center" class="style35">
<b>You HaveCurrently
<asp:Label ID="Label8" runat="server" Text="0"></asp:Label>
Ads</b></td>
</tr>
</table>
</div>
<div style="height: 68px; width: 890px">
<table style="width: 100%; height: 68px;">
<tr>
<td class="style20" align="center">
Do You Want To Post Ads</td>
<td class="style19" align="center">
<asp:Button ID="Button7" runat="server" BorderColor="#B9B9B9"
BorderStyle="None" Height="36px" onclick="Button7_Click" Text="Post AD"
Width="119px" />
</td>
</tr>
</table>
</div><hr />
<div width: 890px">
<asp:GridView ID="GridView1" runat="server"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
Font-Bold="False" Font-Size="Small" Font-Strikeout="False" ForeColor="Black"
GridLines="None" Height="50px"
onrowdeleting="GridView1_RowDeleting1" ShowHeader="False" Width="890px">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table style="width: 454px; height: 140px;">
<tr>
<td class="style22" rowspan="2">
<asp:Image ID="Image1" runat="server" Height="80px"
ImageUrl='<%# Eval("ImagePath") %>' Width="97px" />
</td>
<td align="center" class="style29" width="86px">
AdType:-</td>
<td class="style30">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("AdType") %>'></asp:Label>
</td>
<td class="style31" width="86px">
Location:-</td>
<td class="style30">
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Location") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="style32" width="86px">
Description:-</td>
<td colspan="3" width="100px">
<asp:Label ID="Label3" runat="server" Text='<%# Bind("DescriptionofAd") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="style25">
AdId:-<asp:Label ID="Label6" runat="server" Text='<%# Bind("AdId") %>'></asp:Label>
</td>
<td class="style26" width="86px">
Contact Via:-</td>
<td class="style27">
<asp:Label ID="Label5" runat="server" Text='<%# Bind("ConnectVia") %>'></asp:Label>
</td>
<td class="style28" width="64px">
CreationDate:-</td>
<td class="style27">
<asp:Label ID="Label4" runat="server" Text='<%# Bind("CreationDate") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="delete"
ImageUrl="~/images/icon-delete.gif" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div><hr /></asp:Panel>
<div style="height: 41px; width: 890px">
<asp:Panel ID="Panel2" runat="server">
<table style="width: 100%; height: 38px;">
<tr>
<td class="style11">
<asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click">UpdateMyDetails</asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">ChangePassword</asp:LinkButton>
</td>
</tr>
</table>
</asp:Panel>
</div>
<div style="height: 100%; width: 890px">
<asp:Panel ID="Panel3" runat="server">
<table style="width: 100%;">
<tr>
<td class="style34">
Current Password</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style34">
New Password</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style34">
ReType Password</td>
<td>
<asp:TextBox ID="TextBox3" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style12">
</td>
<td>
<asp:Button ID="Button6" runat="server" onclick="Button6_Click"
Text="ChangeMyPassword" Width="130px" />
</td>
</tr>
</table>
</asp:Panel>
</div>
<div style="height: 100%; width: 890px">
<asp:Panel ID="Panel4" runat="server" onload="Panel4_Load">
<table style="width: 100%;">
<tr>
<td class="style13">
<span class="style18">Name</span> </td>
<td>
<asp:TextBox ID="TextBox4" runat="server" ReadOnly="True"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style33" align="justify">
Contact</td>
<td>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style33">
EmailId</td>
<td>
<asp:TextBox ID="TextBox6" runat="server" ReadOnly="True"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style13">
</td>
<td>
<asp:Button ID="Button5" runat="server" Text="UpdateMyDetails" Width="122px"
onclick="Button5_Click" />
</td>
</tr>
</table>
</asp:Panel>
</div>
<div style="height: 100%; width: 890px">
<asp:Panel ID="Panel5" runat="server" onload="Panel5_Load">
<asp:GridView ID="GridView2" runat="server" AllowPaging="False"
AutoGenerateColumns="False" Height="50px"
CellPadding="4" ForeColor="Black" GridLines="None"
Width="886px" AllowSorting="True"
ShowHeader="False"
Font-Bold="False" Font-Size="Small" Font-Strikeout="False" >
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td rowspan="4">
<asp:Image ID="Image1" runat="server" ImageUrl = '<%# Eval("ImagePath") %>'
Width="100px" /> </td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("AdType") %>'></asp:Label></td>
<td rowspan="4">Title:-
<asp:Label ID="Label2" runat="server" Text='<%# Bind("DescriptionofAd") %>'></asp:Label></td>
</tr>
<tr>
<td>Contact:-
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Contact") %>'></asp:Label></td>
</tr>
<tr>
<td>Address:-
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Location") %>'></asp:Label></td>
</tr>
<tr>
<td>Date:-
<asp:Label ID="Label5" runat="server" Text='<%# Bind("CreationDate") %>'></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</asp:Panel></div>
<div style="height: 41px; width: 890px"></div>
<div style="height: 41px; width: 890px"></div>
</div>
<!-- end #content -->
</div>
<!-- end #sidebar -->
<div style="clear: both;"> </div>
</div>
<!-- end #page -->
</div>
<%--<div id="footer-content">
<div id="footer-bg" class="container">
<div id="column1">
<h2>Welcome to my website</h2>
<p>eassy2connect.com is services provider in complete India.website Provide basic Information for all kinds of classes. Like Math Class,Dance Class in anywhere in noida,Indirapuram ETC</p>
</div>
<div id="column2">
<h2>Our Service</h2>
<p>Provide Information About All Classes<br />
Register here for Home tuition /Tutors<br />
Register your Room or Flat<br />
Register Your Institute</p> </div>
<%--<div id="column3">
<h2>Recommended Links</h2>
<ul>
<li><a href="#">Consectetuer adipiscing elit</a></li>
<li><a href="#">Metus aliquam pellentesque</a></li>
<li><a href="#">Suspendisse iaculis mauris</a></li>
<li><a href="#">Urnanet non molestie semper</a></li>
<li><a href="#">Proin gravida orci porttitor</a></li>
</ul>
</div>--%>
</div>
</div>
<div id="footer">
<p>Copyright (c) 2012 . All rights reserved. Design by .com/">Eassyconnect.com</a>.</p>
</div>
<!-- end #footer -->
</form>
</body>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class UserInter : System.Web.UI.Page
{
SqlCommand cmd;
SqlDataReader dr;
string connection;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
Label8.Text = GridView1.Rows.Count.ToString();
Label7.Text = Session["sd"].ToString();
Panel2.Visible = false;
Panel4.Visible = false;
Panel3.Visible = false;
Panel5.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
Panel5.Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Panel3.Visible = false;
Panel4.Visible = true;
Panel5.Visible = false;
}
protected void Button7_Click(object sender, EventArgs e)
{
Response.Redirect("NewRegistert.aspx");
}
protected void Panel4_Load(object sender, EventArgs e)
{
string connection;
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
string str = "select FirstName,MobileNo,EmailId from Account where FirstName ='" + Label7.Text + "'";
cmd = new SqlCommand(str, con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
Session["Name"] = TextBox4.Text = dr["FirstName"].ToString();
TextBox5.Text = dr["MobileNo"].ToString();
Session["Mail"] = TextBox6.Text = dr["EmailId"].ToString();
}
con.Close();
}
protected void Button6_Click(object sender, EventArgs e)
{
string connection;
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
string str = "update Account set Password = '" + TextBox2.Text + "', ConfirmPassword = '" + TextBox3.Text + "' where FirstName='" + Label7.Text + "'";
cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Thanks - your password has now been updated')</script>");
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
Panel2.Visible = true;
Panel4.Visible = true;
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Panel2.Visible = true;
Panel3.Visible = true;
}
private void BindData()
{
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
string query = @"SELECT * FROM AdvertisementInformation where EmailId = '" + Session["userPageEmail"].ToString() + "'";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
{
Label le = (Label)GridView1.Rows[e.RowIndex].FindControl("Label6");
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
SqlCommand cmd = new SqlCommand("delete from AdvertisementInformation where AdId=" + le.Text, con);
int result = cmd.ExecuteNonQuery();
con.Close();
BindData();
}
protected void Button5_Click(object sender, EventArgs e)
{
string connection;
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
string strr = "update Account set MobileNo = '" + TextBox5.Text + "' where FirstName='" + Session["userPageEmail"].ToString() + "'";
cmd = new SqlCommand(strr, con);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Thanks - your Account information has been updated')</script>");
}
protected void Button8_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = false;
Panel3.Visible = false;
Panel4.Visible = false;
Panel5.Visible = true;
}
protected void Panel5_Load(object sender, EventArgs e)
{
connection = ConfigurationSettings.AppSettings["con"].ToString();
SqlConnection con = new SqlConnection(connection);
con.Open();
string ret = "select * from AdvertisementInformation where SubCategory ='eassy2connect fun'";
cmd = new SqlCommand(ret, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
con.Close();
}
}
Friday, 4 January 2013
How to send mail with out using gmail in asp.net
How to send mail with out using gmail in asp.net
<table style="width: 587px">
<tr>
<td class="style12">
<div>
<div class="style9" style="height: 43px">Send Your Query Here</div>
<div>
<asp:Label ID="Name" runat="server" Text="Your Name*:" style="font-weight: 700"/><br/>
<asp:TextBox ID="txtName" runat="server" Height="31px" Width="507px"
/>
<asp:RequiredFieldValidator ID="RV1" runat="server"
ControlToValidate="txtName"
ErrorMessage="Please Enter Your Name"
SetFocusOnError="True">*
</asp:RequiredFieldValidator><br />
</div>
<div>
<asp:Label ID="Email" class="eassy" runat="server" Text="Email*:" style="font-weight: 700"/><br/>
<asp:TextBox ID="txtMail" runat="server" Width="507px" Height="28px"/>
<asp:RequiredFieldValidator ID="RV2" runat="server"
ControlToValidate="txtMail"
ErrorMessage="Your Email Address"
SetFocusOnError="True">*
</asp:RequiredFieldValidator><br />
</div>
<div>
<asp:Label ID="Sub" runat="server" Text="Subject*:" style="font-weight: 700"/><br/>
<asp:TextBox ID="txtSubject" runat="server" Width="507px" Height="31px"/>
<asp:RequiredFieldValidator ID="RV3" runat="server"
ControlToValidate="txtSubject"
ErrorMessage="Reason to contact us"
SetFocusOnError="True">*
</asp:RequiredFieldValidator><br />
</div>
<div>
<asp:Label ID="Message" runat="server" Text="Feedback:" style="font-weight: 700"/><br/>
<asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine" Width="507px"
Height="81px"/>
<asp:RequiredFieldValidator ID="RV4" runat="server"
ControlToValidate="txtMessage"
ErrorMessage="Please write your feedback"
SetFocusOnError="True">*
</asp:RequiredFieldValidator><br />
</div>
<div>
<asp:Button ID="Button1" runat="server" Text="Send Info"
onclick="Button1_Click" />
</div>
<asp:ValidationSummary ID="ValidationSummary1"
runat="server"/>
<asp:Label ID="Label1" runat="server" Font-Size="Large"/>
</div>
<%--<table style="width: 580px">
<tr><td>YourQuestion</td><td>
<asp:TextBox ID="TextBox2" runat="server" Width="245px"></asp:TextBox>
</td></tr>
<tr><td>Comment</td><td>
<asp:TextBox ID="TextBox7" runat="server" Height="55px" TextMode="MultiLine"
Width="245px"></asp:TextBox>
</td></tr>
<tr><td>Your Email Id</td><td>
<asp:TextBox ID="TextBox3" runat="server" Width="245px"></asp:TextBox>
</td></tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click"
ToolTip="Submit" />
</td>
</tr>
</table>--%>
</td>
</tr>
</table>
use name space :-using System.Net.Mail;
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage feedBack = new MailMessage();
feedBack.To.Add("emailId");
feedBack.From = new MailAddress("emailId");
feedBack.Subject = txtSubject.Text;
feedBack.Body = "Sender Name: " + txtName.Text + "<br /><br />Sender Email: " + txtMail.Text + "<br /><br />" + txtMessage.Text;
feedBack.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("emailId", "password");
//Or your Smtp Email ID and Password
smtp.Send(feedBack);
Label1.Text = "Thanks for contacting us";
}
{
MailMessage feedBack = new MailMessage();
feedBack.To.Add("emailId");
feedBack.From = new MailAddress("emailId");
feedBack.Subject = txtSubject.Text;
feedBack.Body = "Sender Name: " + txtName.Text + "<br /><br />Sender Email: " + txtMail.Text + "<br /><br />" + txtMessage.Text;
feedBack.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("emailId", "password");
//Or your Smtp Email ID and Password
smtp.Send(feedBack);
Label1.Text = "Thanks for contacting us";
}
Subscribe to:
Comments
(
Atom
)
