Get a Cell value in Gridview using C#.net .Implement these code into the Gridview's DataBound Event .Find Header Row in the Gridview and to replace some value into the Cell corresponding Header Row.
#region Set Female and Male Value into the Personal Gridview
protected void grdPersonalDetails_DataBound(object sender, EventArgs e)
{
GridViewRow headerRow = grdPersonalDetails.HeaderRow;
for (int iIndex = 0; iIndex < headerRow.Cells.Count; iIndex++)
{
//Get Header Name
string strHeaderName = headerRow.Cells[iIndex].Text.ToString();
if (strHeaderName == "Gender")
{
for (int iValue = 0; iValue < grdPersonalDetails.Rows.Count; iValue++)
{
//Get Cell value
string strGender = grdPersonalDetails.Rows[iValue].Cells[iIndex].Text; //Check Male
if (strGender == "1")
{
grdPersonalDetails.Rows[iValue].Cells[iIndex].Text = "Male";
}
//check Female
if (strGender == "2")
{
grdPersonalDetails.Rows[iValue].Cells[iIndex].Text = "Female";
}
}
break;
}
}
#endregion
tag:-Get a Cell value in Gridview using C#.net .Implement these code into the Gridview's DataBound Event .Find Header Row in the Gridview and to replace some value into the Cell corresponding Header Row.
Articles
- Articles(C#.NET) (3)
- ASP.NET (6)
- Asp.Net(Email) (1)
- Asp.net(Image) (2)
- Asp.Net(Web.Config) (2)
- C#.NET (5)
- C#.NET Threading (3)
- C#.NET(ASP.NET) (4)
- Comments in PHP (1)
- Encryption In PHP (1)
- iPhone (Articles) (1)
- JavaScript (1)
- Json with PHP (1)
- LINQ (1)
- PHP (2)
- PHP Constant (1)
- PHP Operators (1)
- PHP Print Command (1)
- PHP Tutorial (2)
- Strings In PHP (1)
- Variable Declaration In PHP (1)
- WPF (1)
- XAML (2)
About Me
Help Link
Followers
Find Header Row in Gridview using C#.net .Implement these code into the Gridview's DataBound Event .Find Header Row in the Gridview and to replace some value into the Cell corresponding Header Row.
#region Set Female and Male Value into the Personal Gridview
protected void grdPersonalDetails_DataBound(object sender, EventArgs e)
{
GridViewRow headerRow = grdPersonalDetails.HeaderRow;
for (int iIndex = 0; iIndex < headerRow.Cells.Count; iIndex++)
{
//Get Header Name
string strHeaderName = headerRow.Cells[iIndex].Text.ToString();
if (strHeaderName == "Gender")
{
for (int iValue = 0; iValue <>string strGender = grdPersonalDetails.Rows[iValue].Cells[iIndex].Text; //Check Male
if (strGender == "1")
{
grdPersonalDetails.Rows[iValue].Cells[iIndex].Text = "Male";
}
//check Female
if (strGender == "2")
{
grdPersonalDetails.Rows[iValue].Cells[iIndex].Text = "Female";
}
}
break;
}
}
#endregion
tag:-Find Header Row in Gridview using C#.net .Implement these code into the Gridview's DataBound Event .Find Header Row in the Gridview and to replace some value into the Cell corresponding Header Row.
We can edit,delete,add keys and values into Ap.config using C#.NET ?
First off all using system.configuration.dll (if not exist) then using namespace System.Configuration
Then add app.config file
that file contain only appSettings tag
Call this Function "SaveConfigValue"
SaveConfigValue(strkeyDatabaseType, strType);
SaveConfigValue(strkeyServer, strServer);
SaveConfigValue(strkeyUsername, strUserName);
SaveConfigValue(strkeyPassword, strPass);
SaveConfigValue(strkeyDatabase, strDatabase);
#region Save Database Settings into Config File
///
/// Save Database Settings into Config File
///
///
///
///
private bool SaveConfigValue(string strKey, string strValue)
{
bool bRet = true;
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Remove(strKey);
config.AppSettings.Settings.Add(strKey, strValue);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
bRet = false;
}
return bRet;
}
#endregion
#region Load DataBaseSettings
///
/// Load Database settings from Config File
///
///
private bool LoadConfigValue()
{
bool bRet = true;
try
{
ConfigurationManager.RefreshSection("appSettings");
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
foreach (string strKey in config.AppSettings.Settings.AllKeys)
{
string strVal = ConfigurationManager.AppSettings[strKey].ToString();
switch(strKey)
{
case strkeyDatabaseType:
{
if (strVal == strDatabaseTypeAccess)
{
radioButtonAccess.Checked = true;
}
else
{
radioButtonSqlServer.Checked = true;
}
break;
}
case strkeyServer:
txtServer.Text = strVal;
break;
case strkeyUsername:
txtUserName.Text = strVal;
break;
case strkeyPassword:
txtPassword.Text = strVal;
break;
case strkeyDatabase:
txtConnectionString.Text = strVal;
break;
}
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
bRet = false;
}
return bRet;
}
#endregion
#tag:-Add,Delete,Edit App.config File Using C#.Net
// Executing external applications in C#.Net (using process)
/*
Before we begin creating any methods, we must include System.Diagnostics namespace(using System.Diagnostics), witch contains the Process class.
Also, we must declare a private variable of type Process in our class.
Let's name the variable p.
*/
/// Start Your Process
private void btnStart_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = txtProcessName.Text.Trim();
p.Start();
}
/// Browse your Executable Programs
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog dlgOpenFileDialog = new OpenFileDialog();
if (dlgOpenFileDialog.ShowDialog() == DialogResult.OK)
{
txtProcessName.Text = dlgOpenFileDialog.FileName;
}
}
//In this case you can type any executable commands into the textbox (cmd,notepad,mspaint ..etc) or browse
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language . JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
JSON is built on two structures:
* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.
In JSON, they take on these forms:
An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.
A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.
Whitespace can be inserted between any pair of tokens. Excepting a few encoding details, that completely describes the language.
Example :
object
{}
{ members }
members
pair
pair , members
pair
string : value
array
[]
[ elements ]
elements
value
value , elements
value
string
number
object
array
true
false
null
-----------------
string
""
" chars "
chars
char
char chars
char
any-Unicode-character-
except-"-or-\-or-
control-character
\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits
number
int
int frac
int exp
int frac exp
int
digit
digit1-9 digits
- digit
- digit1-9 digits
frac
. digits
exp
e digits
digits
digit
digit digits
e
e
e+
e-
E
E+
E-
tag:-JSON with PHP Introduction
The crypt() Function
In PHP we can use the crypt () function to create one way encryption. This means that the data is encrypted but cannot easily be decrypted.
When a user chooses their password, the password is then encrypted and the encrypted version of this password is saved. The next time the user goes to login, their password is encrypted again and then checked against the already saved (encrypted) version to see if they are the same. This way if the data is intercepted, they only ever see the encrypted version.
The crypt function is phrased as: crypt ( input_string, salt)
In this case input_string is the string you would like to encrypt (your password for example,) and salt is an optional parameter that influences how the encryption will work. PHP by default uses a two character DES salt string. If your system standard is MD5, a 12-character salt string is used.
The following are the four types of salt that work with all crypt () functions.
CRYPT_STD_DES - Standard DES-based encryption with a two character salt
CRYPT_EXT_DES - Extended DES-based encryption with a nine character salt
CRYPT_MD5 - MD5 encryption with a twelve character salt starting with $1$
CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt starting with $2$ or $2a$
when we use crypt ()
<?php $password = crypt('mypassword'); print $password . %u201C is the encrypted version of mypassword%u201D; ?>
This will output the encrypted version of ‘mypassword’ for you to see. Now let’s try it using different types of salt.
<?
php $password = crypt('mypassword' , 'd4');
print $password . " is the CRYPT_STD_DES version of mypassword<br>";
$password = crypt('mypassword' , 'k783d.y1g');
print $password . " is the CRYPT_EXT_DES version of mypassword<br>";
$password = crypt('mypassword' , '$1$d4juhy6d$');
print $password . " is the CRYPT_MD5 version of mypassword<br>";
$password = crypt('mypassword' , '$2a$07$kiuhgfslerd...........$');
print $password . " is the CRYPT_BLOWFISH version of mypassword<br>";
?>
This will output something like this:
d4/qPbCcJ5tD. is the CRYPT_STD_DES version of mypassword
k7xEagYCDPPSc is the CRYPT_EXT_DES version of mypassword
$1$d4juhy6d$a.jIPYnvne1FWF2V6mGQR0 is the CRYPT_MD5 version of mypassword
$2a$07$kiuhgfslerd...........6k0kSI76CqJ/RWGnSp9MWRDF91gJZfW is the CRYPT_BLOWFISH version of mypassword
tag:- crypt() funtion for data encryption in PHP