Friday, October 22, 2010

જે કશું જ જાણતો નથી અને એ પણ નથી જાણતો

જે કશું જ જાણતો નથી અને એ પણ નથી જાણતો
કે એ કશું જ જાણતો નથી એ મૂર્ખ છે – છોડો એને !
જે કશું જ જાણતો નથી અને જાણે છે કે એ
કશું જ જાણતો નથી એ સામાન્ય છે – શીખવો એને !
જે કંઈક જાણે છે પણ એને જાણ નથી કે
તે જાણે છે તે નિદ્રામાં છે – જગાડો તેને !
જે જ્ઞાની છે અને તેના જ્ઞાન વિષે સભાન છે
તે શાણો છે – અનુસરો એને !

દુ:ખી થવાના દસ રસ્તા

(ક) તમારી જ વાત કર્યા કરો
(ખ) તમારો જ વિચાર કર્યા કરો.
(ગ) ‘કદર’ ‘કદર’ ઝંખ્યા કરો.
(ઘ) કોઈ તમારી ઉપેક્ષા કરે તો બળ્યા કરો.
(ચ) કોઈનો યે વિશ્વાસ ન કરો.
(છ) તમારી ફરજમાંથી શક્ય ત્યાં સુધી છટકી જાવ.
(જ) બને તેટલી વાર ‘હું’ શબ્દનો ઉપયોગ કરો.
(ઝ) બીજા માટે બને તેટલું ઓછું કરો.
(ટ) તમારી મહેરબાની બદલ લોકો આભાર ન માને તો સમસમ્યા કરો.
(ઠ) દરેક બાબતમાં તમારો જ કક્કો ઘૂંટ્યા કરો.

Saturday, September 11, 2010

How to connect linq to sql:-

1.Add New Item -->LINQ to SQL classes
It will create 3 files in App_Code Folder
1.Whatever you name created.dbml
2.Whatever you name created.dbml.layout
3.Whatever you name created.dbml.cs
2.Open .dbml file
It will totally blank with two part.
3.Drag and drop all the tables in the dbml file.
When you drop tables it will automatically create relationship between tables as per primary key and foreign key.
4.Now you are ready to use linq to sql

First create the object of that lind class
Suppose name is HotelDb then create object as shown
HotelDbDataContext obj=new HotelDbDataContext();
It will by default attach DataContext with class name.
Now all the table names converted in the plural(Bahuvachan)
e.g. City become cities etc.
Now to select all the data from table
Griedview1.datasource=obj.tablename in plural(It will display in dropdown)
Griedview.databind();

Wednesday, April 7, 2010

Difference Between two Dates in asp.net

There are two textbox in which there are dates:
Following c# coding will calculate days between these two date and will display in Label.



DateTime dt1=Convert.toDateTime(TextBox1.text);

DateTime dt2=Convert.toDateTime(TextBox2.text);
TimeSpan ts=dt2.Substract(dt1);
Label1.text=ts.days.toString();

Tuesday, March 30, 2010

Order by clause in LINQtosql

Fetch All city order by city name:

dataContext _Data= new dataContext();

var qry = from a in _Data.Cities

orderby a.CName
select a;

Thursday, March 11, 2010

Wednesday, March 10, 2010

ViewState in asp.net

protected void Page_Load(object sender, EventArgs e)
{
ViewState["id"] =Label1.Text;
}

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = (Convert.ToInt32(ViewState["id"])+1).ToString();
ViewState["id"] = Label1.Text;
}

Logout in Asp.net

protected void Page_Load(object sender, EventArgs e)
{
if (Session["id"] == null)
{
Response.Redirect("Default2.aspx");
}
Label1.Text = Session["id"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.Abandon();
}

Disable Copy And Paste In TextBox Control in asp.net

<script language="javascript">
function copy()
{
alert("Can't copy the text");
return false;
}
function paste()
{
alert("can't paste text");
return false;
}
</script>

<asp:TextBox ID="TextBox2" runat="server" Text="hi" oncopy="return copy();" onpaste="return paste();"></asp:TextBox>