The mountain is my father

I say help me

He said what

problem do you need help with,

I say heal me,

He stays with me until I feel better,

I say buy this book,

He said Okey,

I say I’m tired on the mountain,

He said we’ll rest

for a while,

I am feeling warm from the bottom of my heart, and also I am feeling higher pressure because I know being a mountain is not that easy. Hehe, sweet heart, let me try that,……

This is best gift I had! I am proud of that she can write a poem now, when she is almost nine year old!

email is not a primary but can not be duplicated, otherwise, the same query would get different result. I have a DetailsView bound to a SqlDataSource and then call a sproc to insert a new record. The simple solution to keep from creating two records with one same email is to set the email field as a unique index:

Create Unique Index indx_tablename_columnName On tableName (columnName)

When somebody tried to create a dup record, SqlDataSource1_ItemInserted would get an error message. Then, we can capture it and do something else…

The better way is to modify the sproc as:

Create Proc [Sp_Insert]
@email varchar(128),
……
@returnValue  int output
As
If Exists(Select * From theTable Where email=@email)
Begin
Set @returnValue = 0
End
Else
Begin
Insert Into theTable (email,…) Values(@email,…)
Set @returnValue = 1
End

So get a flag in SqlDataSource1_ItemInserted, instead of an error message, no error happened in SQlServer.

free download links

June 17, 2009

There are many book/movie/audio links for FREE download in linkentity.com. And there is a link that keeps all the nominees and winners’ works of Hugo Awards from 1946-2006. I am surprised because there is not a collection published for it, so the collector must be a big science fiction fan. But an interesting is that the wiki says:

“……The Hugo Awards are given every year for the best science fiction or fantasy works and achievements of the previous year. The award is named after Hugo Gernsback, the founder of the pioneering science fiction magazine Amazing Stories. Hugo Awards have been presented every year since 1955…..”

Then,  what is it from 1946-1954, in the collection?

Solution1:  enable GET+POST for web service in web.config by adding the following inside <System.web>…<//system.web>:

<webServices>
<protocols>
<add name=”HttpGet”/>
<add name=”HttpPost”/>
</protocols>
</webServices>

what is web service?

June 16, 2009

web service is a web-based application without user interface, it has two sides: client and server sides that could be programmed in differrent programming languages, be running in the different operating systems and be exchanging SOAP (simple object access protocal) messages based on  XML documents through HTTP.

Sometimes, if you don’t need to understand, just keep it in mind. The output format of type Double is in this case:

  • String.Format(“{0:0.00}”, 123.4567);    //fixed two digit decimal:  “123.46″
  • String.Format(“{0:0.##}”, 123.4567); // max two digit decima: “123.46″
  • String.Format(“{0:00.0}”, 3.4567); // fixed two digits before point: “03.5″
  • String.Format(“{0:0,0.0}”, 12345.67); // thousand separator: “12,345.7″
  • String.Format(“{0,10:0.0}”, 123.4567); //positioning:  “       123.5″
  • String.Format(“{0,-10:0.0}”, 123.4567); //positioning:  “123.5        “
  • String.Format(“{0:0aaa.bbb0}”, 12.3); // add in none-digit chars:  “12aaa.bbb3″
  • …continue later…

1. change the pager item width:

.cssPager td
{
padding-left: 3px;
padding-right: 3px;
}

2. Set the color, bgColor, fontSize of the selected item of the pager:

.cssPager span { background-color:#567891; font-size:16px; color:White; font-weight:bold; }

Here is an article discussing the tricks and tips on GridView Pager. Anyway those are not good staff that .net provides.

A bak file is generated for backup a database structure and data. If you want to restore a bak file from SQL Server database, you can do it with SQL Server management studio express as followed:

  1. start SQL Server Management Studio Express ( I am using SQL Server 2005 express);
  2. create a new empty database “aNewDb”;
  3. right click on Databases in Object Explorer;
  4. select  “Restore Database”, and then Restore Database window pops up;
  5. select the new-created database “aNewDb” to “To database:” box;
  6. check “From device:” and go find the bak file, and then one record should show up in backup sets;
  7. check the checkBox in the sets list for restore;
  8. click “Options” on the left, and MUST check “Overwrite the existing database”;
  9. MUST make sure that the files for “Restore As” are of the “aNewDb”, but sysft_aNewDb’s path could not be same as the path of the mdf and ldf files.
  10. click “OK”, and done!

You would get the new database with the backup data.

I only tried IE7.0, but it did donot work well if you have this setting in your GridView:

<asp:GridView ID=”GridView1″ runat=”server” BorderColor=”red” BoderStyle=”Solid” BorderWidth=”1px” RowStyle-BorderColor=”blue” RowStyle-BorderStyle=”Solid” RowStyle-BorderWidth=”1px” ……>

<……/>

But using css works:

1. create css class

<style type=”text/css”>
table.GridViewCss  td,th
{
height:25px;
color:#333333;
border:solid 1px #6A8CA5;
border-collapse: collapse;
}

table.GridViewCss
{
height:25px;
color:#333333;
border:solid 1px #6A8CA5;
border-collapse: collapse;

}
</style>

2. use it

<asp:GridView ID=”GridView1″ runat=”server” CssClass=”GridViewCss” ……>

<……/>

I have some linkButtons in GridView, and I want to call a client-side javascript method with bound data when user click on it.

<asp:LinkButton OnClientClick=’<%# “alert(‘” + Eval(“something”) + “‘)” %>’ ……>

unfortunately, it doesn’t work.

<asp:LinkButton OnClientClick=’<%#  Eval(“something”, “alert(‘{0}’)” %>’ ……>

it doesn’t work too.

Only works for me when use codebehind:

protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
 if (e.Row.RowType == DataControlRowType.DataRow)
 {
 LinkButton lnkbtn = (LinkButton)e.Row.FindControl("lnkbtn");
 string st= DataBinder.Eval(e.Row.DataItem, "something").ToString();
 lnkbtn.Attributes.Add("onclick", string.Format("alert('{0}')", st));
 }
}