Posted by Unknown on 5:05 AM
Labels:

Case: I have a gridview listing certain values and i have a checkbox as an item template
I want to build a string by appending checked values in the gridview..
eg:



we can make use of the string builder class for this.

using System.Text;

private string BuildStaffList(GridView grdVw, string chkName)
{
string StaffList = string.Empty;
StringBuilder str = new StringBuilder();
//gvStaff is the name of the GridView
for (int i = 0; i < gvStaff.Rows.Count; i++)
{
GridViewRow row = gvStaff.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("ChkSelect")).Checked;
//chkselect is the name of the checkbox

if (isChecked)
{
str = str.Append(gvStaff.Rows[i].Cells[1].Text.ToString() + "~");
}
}
StaffList = str.ToString();
return StaffList;

}
SUPPOSE I CHECK VALUES 1 & 2
Result:Sandhya Ramakrishnan~Shiju George

Posted by Unknown on 12:47 AM
Labels:

To add a checkall option inside a gridview:

StringBuilder str = new StringBuilder();

// Select the checkboxes from the GridView control

for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
bool isChecked = ((CheckBox) row.FindControl("chkSelect")).Checked;

if (isChecked)
{
// Column 2 is the name column

str.Append(GridView1.Rows[i].Cells[2].Text);
}
}


in the .aspx source(A checkbox is added in the template field)
Also add a checkbox in the header template of the same cell.When thid checkbox is selected all others are selected.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="175px">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input type = checkbox id = "chkid" name = SelectAll onclick = selectall<); />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


Now to add the checkall option,we use javascript

<script language = javascript>
function selectall()
{
var gridview = document.getElementById("GridView1");
for(var i = 1;i < gridview.rows.length; i++)
{
gridview.rows[i].cells[0].firstChild.checked = true;
}
}
</script>

Posted by Unknown on 12:59 AM
Labels:

JavaScript is a scripting language widely used for client-side web development.
JavaScript, despite the name, is essentially unrelated to the Java programming language,
although both have the common C syntax, and JavaScript copies many Java names and naming conventions.
The language's name is the result of a co-marketing deal between Netscape and Sun.


JAvascript is embedded within html.

A simple Hello World Example:

<html>
<head>
<title>HEllo World using Javascript</title>
<script language="JavaScript">
document.write<"Hello World!">;
</script>
</head>
<body>
...body code goes here...
</body>
</html>

We can include the below for browsers tat wont support javascript

<noscrip>
.....
</noscript>

Above we see that the script is included within the (head)(/head) tags.But we can include the script within the (body) also.

<body>
<script language="JavaScript">
!--
document.write("Hello World");
// --)
</script>

We can also include an external javascript file for our page

<script language="JavaScript" src="hello.js"></script>

above we have seen that to output text we use the write() or writeln() methods of the document object..

document.write("Hello World");

Document object can also be used to change the background color or foreground color.

document.bgColor="black"
document.fgColor="white"


We all have noticed messageboxes on webpages..Javascript has basically three types of messageboxes:

alert
confirm
prompt

window.alert("Invalid!")

window.confirm("Are you sure you want to quit?")

window.prompt("Enter ur username here")

We can also write it as alert(),confirm(),or prompt()

Variable declaration in JavaScript is done using var

var x=window.prompt("Enter your username");
window.alert(x);

Functions are used to include chunks of code and call the javascript code on events.

<script>
function ss<>
{
alert<"Thank you!">
}
</script>

Events are triggers that are executed when something like click,load etc happens..

OnClick

<script>
function btnClick<>
{
alert<"Thanks">
}
</script>
<form>
<input type="button" value="Click here" onclick="btnClick()">
</form>

onLoad

<body onload="Function_name()">
<frameset onload="Function_name()">

onUnload

<body onunload="alert(GoodBye)">

Multiple actions in an events can be separated using ";"

onclick="btnClcik();alert("Welcome")"

onFocus, onBlur and onChange

<input type="text" onChange="function()">

The above OnChange event will be called when the text is changed..
Likewise the OnFocus and OnBlur events

OnBlur is fired when the textbox or object loses focus

<input type="text" onblur="validateValue(this)">

onSubmit

It is used before submitting the form

<form method="post" action="MyPage.html"
onsubmit="function()">

onMouseOver and onMouseOut

Used to create animated buttons..Fires when the mouse is over the object.

onMouseOver="window.status='Click here to goto MyPAge.html'; return true"

OnKeyUp,OnKeyDown,OnKeyPress,OnDblClick(double click)

Cookies

Cookies are stored in the client side.

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i ( ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {
createCookie(name,"",-1);
}

Posted by Unknown on 10:29 PM
Labels:




Most of us have seen a statue of the "Laughing Buddha" or probably bought one..A symbol for good luck,the "laughing buddha" is a showcase item in almost every house..

The laughing buddha is known by differenty names.He was named "Hotei" in Japan, "Pu-Tai" by the Chinese.He is also known as Loving or the friendly one.He is based on an eccentric
 Chinese Ch'an (Zen) monk who lived over 1,000 years ago and has become a significant part
 of Buddhist and Shinto culture.

His large protruding stomach and jolly smile have given him the common designation "Laughing Buddha."The legend says that,rubbing the great belly of the laughing buddha brings you luck,wealth etc..


The Laughing Buddha emerged from Chinese folktales of the 10th century.
The Chinese laughing Buddha is associated to a roving Ch'an (Zen) monk,"Ch'i-t'zu" of the Liang Dynasty in China,who did small wonders like predicting weather,fortune etc
 
He was famous for his benevolent and cheerful nature. He used to carry a cloth like bag wherever he went.The bag was called ‘Pu- Tai’ in indigenous Chinese language. Hence the monk came to be known as ‘Pu-tai Hoshang’ or ‘hemp-bag monk’



   



Posted by Unknown on 1:14 AM
Labels:

Filling a Dropdownlist inside a gridview with database values:

EG:
protected void gdLabHourSetting_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlSession = (DropDownList)e.Row.FindControl("ddlSession");

if (ddlSession != null)
{
ddlSession.DataSource = tblLabSession;
ddlSession.SelectedIndex = ddlSession.SelectedIndex < lblsession =" ((Label)(gdLabHourSetting.Rows[e.NewEditIndex].Cells[1].FindControl(" editindex =" e.NewEditIndex;" ddlsession =" ((DropDownList)(gdLabHourSetting.Rows[e.NewEditIndex].Cells[1].FindControl(" datasource =" tblLabSession;" datatextfield =" tblLabSession.Columns[" datavaluefield =" tblLabSession.Columns[" idx =" ddlSession.Items.IndexOf(ddlSession.Items.FindByText(lblSession.Text.Trim()));" selectedindex =" ddlSession.Items.IndexOf(ddlSession.Items.FindByText(lblSession.Text.Trim()));" style="font-weight: bold;">Adding data through gridview into DB:

Make the command field as a template column and add a link button to its footer template:

Eg:

private void FillCustomerInGrid()
{
DataTable dtCustomer= customer.Fetch();

if (dtCustomer.Rows.Count>0)
{
GridView1.DataSource = dtCustomer;
GridView1.DataBind();
}
else
{
dtCustomer.Rows.Add(dtCustomer.NewRow());
GridView1.DataSource = dtCustomer;
GridView1.DataBind();

int TotalColumns = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
GridView1.Rows[0].Cells[0].Text = "No Record Found";
}
}

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtNewName=(TextBox)GridView1.FooterRow.FindControl("txtNewName");
DropDownList cmbNewGender = (DropDownList)GridView1.FooterRow.FindControl("cmbNewGender");
TextBox txtNewCity = (TextBox)GridView1.FooterRow.FindControl("txtNewCity");
TextBox txtNewState = (TextBox)GridView1.FooterRow.FindControl("txtNewState");
DropDownList cmbNewType = (DropDownList)GridView1.FooterRow.FindControl("cmbNewType");

customer.Insert(txtNewName.Text, cmbNewGender.SelectedValue, txtNewCity.Text, txtNewState.Text, cmbNewType.SelectedValue) ;
FillCustomerInGrid();
}
}

Posted by Unknown on 11:28 PM
Labels:

Atheism....well this title itself would raise some eyebrows!!! Well, sorry to disappoint you friends....

 First of all let’s see who is called an atheist...

 "Atheism, as an explicit position, can be either the affirmation of the nonexistence of gods, or the rejection of theism. It is also defined more broadly as an absence of belief in deities, or no theism"

 The term Atheist originated as a pejorative epithet applied to any person or belief in conflict with established religion

 One question that i have always wondered in my life is that "why did God create man??"

You would say that that one is not an atheist view!!  I kept wondering and as such i find no reason to believe that God had any reason to actually create man....

Well i kept wondering but never found an answer. Then i asked myself one question "Did God create man or did man create God???"

As always i went into deep thoughts and tried to figure out which could be the possible? At last i got to my conclusion... The latter option is a more logical one i suppose...

 Well the next question that arises is "why did man create God"..Aha...you guys must be wondering whether i will ever stop asking questions to myself and ever get an answer to anyone of them..Ok i think i got an answer to this one though..

 I believe God was created to instill in man, a fear of doing wrong things. Well it was a good concept perhaps. The people who created God believed that by saying that you would be punished for your bad deeds would actually save mankind.Aha that great philosopher would rather call himself an atheist now. What was done to save mankind is actually going to be the doom of mankind.

God was created to save mankind but the same people created "religion". Now there were not one but hundreds of Gods and then people started fighting over who was the better God. Suddenly people started believing that any evil that was done in spreading the idea of his God was no more evil. You can do mass murders and do any evil done to anyone who doesn’t believe in your God. God was created to instill the fear of doing wrong and now that God itself was going to be the reason of many evil deeds.

And then to protect his religion man tried to suppress anything that suggested that God did not exist. The likes of Galileo and Copernicus were tried in suggesting things that was different from the views given by the religious heads. It did not end there. This kind of things still goes on today.

 Even scientific evidence was not enough for people to believe that there is a possibility that all that they believed was wrong..Darwin found that man evolved out of monkeys...but still faithfuls wanted to disagree.And then the most modern experiment of the big bang thoery.That will prove that Earth was not created by God. But people would still want to believe in what was taught to him. 

Ok may be there is a tiny possibility that this experiments were not correct. But let me ask you people one thing. If there was a God, then why isn’t he doing anything to actually stop all this violence? Man is doing all sought of evils in trying to glorify his God and "God" simply stays in heaven watching the tamasha??Well if that is so He doesn’t deserve to be admired. Having the so called power to stop all this and still enjoying all this is never admirable. Do these religious heads want us to believe that anything done in the name of God is the greatest thing that can be done by man??

The argument that may be there is a possibility that there is no God is never entertained though. Why is that?? Well I think it’s because religion is the only organization that will never enter a recession period!!! Even if man does not have anything to eat he is prepared to contribute to religions organizations. Even in times of poverty he will go to the temple or church to pray and contribute hoping for God to help him. The political parties and all those people connected to the religion want this money. So any idea suggesting the non-existence of God is never entertained. People spend so much money in building temples,churches,mosques etc.They are ready to contribute to the religious events and festivals.

 But the same man would never do any good for his fellow being. I still don’t understand one thing. They say that to lead a good life you need to pray and have full faith in God. Anyone who doesn’t pray will never have peace of mind. Ok for once let’s accept that. Even if you do all bad things and still prepared to go and ask for forgiveness from God you can go to heaven. But if you are prepared to help with all your heart and you are an atheist then you are to be doomed. C’mon people. Think…Who the better person here? Was it the one who prayed or the one who helped? What are these people trying to say? I guess they are trying to say that you can do anything but have belief in God and you can be forgiven. In short if you are prepared to do chamchagiri you don’t need to worry. But if you do all good things and never pray then you will be punished. Well then, if that’s the case I see God no less than a landlord. Belief in God is like a license to do anything bad. You can kill, torture, rape and do all sought of evils, but if you believe in God you are safe from Hell. 

All this makes me to believe that there can’t be anyone called as God and even if there is one, He has been defeated by the Satan.