Use the tertiary expression as below,
<%#Eval("Present").ToString()=="True"?"P":"A"%></td>
<%#Eval("Present").ToString()=="True"?"P":"A"%></td>
|
int RandNo = 0;
private int RandomNumber(int min, int max)
{
Random random = new
Random();
return
random.Next(min, max);
}
|
|
protected void Page_Load(object sender, EventArgs e)
{
RandNo =
RandomNumber(10000000, 99999999);
Response.Write(RandNo);
}
|
|
private static Random random = new
Random((int)DateTime.Now.Ticks);//thanks to McAden
private string RandomString(int size)
{
StringBuilder builder =
new StringBuilder();
char ch;
for (int i = 0; i <
size; i++)
{
ch =
Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() +
65)));
builder.Append(ch);
}
return
builder.ToString();
}
|
|
// get random string where everyou require
string Rand = RandomString(4);
|
01 | DROP TABLE dbo.unicodeData |
02 | GO |
03 | CREATE TABLE dbo.unicodeData |
04 | ( languageUsed VARCHAR(50) |
05 | , unicodeData NVARCHAR(200) |
06 | , nonUnicodeData VARCHAR(200) -- same data in a normal VARCHAR column for comparison |
07 | , comments VARCHAR(100) |
08 | ) |
09 | GO |
10 | INSERT INTO dbo.unicodeData (languageUsed, unicodeData, nonUnicodeData, comments) |
11 | VALUES |
12 | ('English', N'This is an example', N'This is an example', NULL) |
13 | , ('Hindi', N'यह एक उदाहरण है.', N'यह एक उदाहरण है.', 'Using the preceding N in both strings but VARCHAR is still a ?') |
14 | , ('Hindi', 'यह एक उदाहरण है.', 'यह एक उदाहरण है.', 'Not using the preceding N in both strings so both are a ?') |
15 | , ('Kannada', N'ಈ ಒಂದು ಉದಾಹರಣೆಯಾಗಿದೆ.', N'ಈ ಒಂದು ಉದಾಹರಣೆಯಾಗಿದೆ.', NULL) |
16 | , ('Arabic', N'هذا مثال على ذلك.', N'هذا مثال على ذلك.', NULL) |
17 | , ('Czech', N'To je příklad.', N'To je příklad.', NULL); |
18 | GO |
19 | SELECT * FROM dbo.unicodeData; |
20 | GO |
21 | -- Example of using N' in the WHERE clause |
22 | SELECT * FROM dbo.unicodeData |
23 | WHERE unicodeData like N'%एक%'; |