Friday, 31 January 2014
Basics of LINQ Join with Lamda Expressions(Inner Join with Linq)...................
01:49
No comments
Basics of LINQ
Join with Lamda Expressions(Inner Join with Linq)...................
Note: In this topic, we will discuss about join with Linq
Concept ……….
--Execute this query in Sql Server…………………………
create database LinqwithJoin
use LinqwithJoin
--Code for Create table
create table StuRecord (id int,Name nvarchar(50),City nvarchar(50))
create table StuCollege(id int,CollegeName nvarchar(50),BranchName nvarchar(50))
-- insert record both table.................
insert into StuRecord values(1,'Kush Tiwari','Ghazipur')
insert into StuCollege values(1,'Sms Varanasi','M.C.A')
-- Join or Inner Join in Sql Server
Select StuRecord.Id,StuRecord.Name,StuRecord.City,StuCollege.CollegeName,StuCollege.BranchName
from StuRecord inner join StuCollege
on StuRecord.id=StuCollege.id
Select r.Id,r.Name,r.City,c.CollegeName,c.BranchName from
StuRecord r join
StuCollege c on r.id=c.id
//Inner Join/Join with Linq Concept using C# .Net..............
//Code for Default.aspx……………………………………….
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!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></title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td colspan="2">
<center> Basics of LINQ Join with Lamda Expressions</center>
</td>
</tr>
<tr>
<td colspan="2"><center>
<asp:Button ID="Button1"
runat="server"
onclick="Button1_Click"
Text="Inner Join With Linq
Concept" /></center>
</td>
</tr>
<tr>
<td colspan="2">
<center> <asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White"
/>
<FooterStyle BackColor="#990000"
Font-Bold="True"
ForeColor="White"
/>
<HeaderStyle BackColor="#990000"
Font-Bold="True"
ForeColor="White"
/>
<PagerStyle BackColor="#FFCC66"
ForeColor="#333333"
HorizontalAlign="Center"
/>
<RowStyle BackColor="#FFFBD6"
ForeColor="#333333"
/>
<SelectedRowStyle BackColor="#FFCC66"
Font-Bold="True"
ForeColor="Navy"
/>
<SortedAscendingCellStyle BackColor="#FDF5AC"
/>
<SortedAscendingHeaderStyle BackColor="#4D0000"
/>
<SortedDescendingCellStyle BackColor="#FCF6C0"
/>
<SortedDescendingHeaderStyle BackColor="#820000"
/>
</asp:GridView></center>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
//Code for Default.aspx.cs……………………………………….
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs
e)
{
}
DataClassesDataContext dd = new DataClassesDataContext();
protected void
Button1_Click(object sender, EventArgs e)
{
// Linq inner join with Old Format…………………………………
var v = from m in dd.StuRecords
from w in
dd.StuColleges
where m.id == w.id
select new { m.id,
m.Name, m.City, w.BranchName, w.CollegeName };
// Linq inner join with New Format………
var v = from m in dd.StuRecords
join s in
dd.StuColleges
on m.id equals
s.id
select new { m.id,
m.Name, m.City, s.BranchName, s.CollegeName };
//Using Linq Lamda Expressions…………………
var v = dd.StuRecords.Join(dd.StuColleges, x =>
x.id, z => z.id, (x, z) => new { x.id,
x.Name, x.City, z.BranchName, z.CollegeName }).ToList();
GridView1.DataSource
= v;
GridView1.DataBind();
}
Thursday, 23 January 2014
How to preview image in asp net with Jquery
23:21
1 comment
How to preview image in asp net with Jquery
Note : we will discuss
how to
use preview image concept with jquery in Asp.net in this topic .First we
will take a Website with Default2.aspx page and download jquery-1.10.2.min.js from www.Jquery.com follow as below code
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default2.aspx.cs"
Inherits="Default2"
%>
<!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></title>
<script src="jquery-1.10.2.min.js"
type="text/javascript"></script>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new
FileReader();
reader.onload
= function (e) {
$('#Image1').attr('src',
e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$(function () {
$("#filephoto").change(function () {
var $this = $(this);
readURL(this);
//alert("This height " + $this.height() + "this
is width" + $this.width());
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="100%"
>
<tr>
<td>
Name</td>
<td style="width:30px" >
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
<td rowspan="3">
<asp:Image ID="Image1" runat="server"
Height="72px"
Width="108px"
/>
</td>
</tr>
<tr>
<td>
User
Image</td>
<td>
<asp:FileUpload ID="filephoto"
runat="server"
/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnsave"
runat="server"
onclick="btnsave_Click"
Text="Save"
/>
</td>
</tr>
</table>
</div>
</form>
</body>
Subscribe to:
Posts (Atom)