Hi All,
I had a requirement where in I want to hide Rectangle (which had tablix and charts inside it) to show and hide based on query string parameters. The requirement was working fine when it is showing the Rectangle but when the rectangle is hiding it is generating Blank Page.
I searched a lot for a solution and came to know one trick which i would like to share with you .
I took a new Table(Tablix) .
Select the Row of the tablix and apply the same visibility expression on the Row visibility that I have applied on Rectangle .
Now drag the rectangle inside the Table row cell , in which you have applied expression .Thats it...!!!
Now check , it will not render Blank page / white space any more... :-)
Point to Note : One thing that only I have noticed and would like to tell you..First apply the Row visibility Expression and then only drag the Rectangle inside the Row cell of the table. This is because , I wasn't able to select the row , if you dragged the Rectangle first.. If you try to select Row, Rectangle gets selected....
Hope it helps!!!
Thanks ,
Nitin Sharma
Showing posts with label Technical. Show all posts
Showing posts with label Technical. Show all posts
Monday, June 9, 2014
Saturday, June 7, 2014
Convert input string to Title case in C#
Hi All,
This post is about how to convert your input string into TITLE case in C#.
You can convert your input string either in C# code or in SQL function (scalar function) :
Convert to Title case in C# :
This post is about how to convert your input string into TITLE case in C#.
First , let me tell you what is title case
:
When writing a name or a title, it is a common
convention to only use capital letters to start the principal words. This is
called Title Case. When using Title Case, do not use capital letters
for prepositions, articles or conjunctions unless one
is the first word.
Examples:
Examples:
- Snow
White and the Seven Dwarfs.
- Newcastle
upon Tyne / Brighton on Sea .
- The
DiMaggio Line .
- The
Last of the Mohicans .
You can convert your input string either in C# code or in SQL function (scalar function) :
Convert to Title case in C# :
public static String TitleCaseString(String
s)
{
if (s == null) return s;
String[] words = s.Split('
');
for (int i = 0; i
< words.Length; i++)
{
if (words[i].Length == 0) continue;
Char firstChar = Char.ToUpper(words[i][0]);
String rest = "";
if (words[i].Length > 1)
{
rest = words[i].Substring(1).ToLower();
}
words[i] = firstChar + rest;
}
return
String.Join("
", words);
}
Convert to Title case in SQL Server function :
CREATE FUNCTION udf_TitleCase (@InputString VARCHAR(4000) )
RETURNS VARCHAR(4000)
AS
BEGIN
DECLARE @Index
INT
DECLARE @Char CHAR(1)
DECLARE
@OutputString VARCHAR(255)
SET
@OutputString = LOWER(@InputString)
SET @Index = 2
SET
@OutputString =
STUFF(@OutputString, 1, 1,UPPER(SUBSTRING(@InputString,1,1)))
WHILE @Index <= LEN(@InputString)
BEGIN
SET @Char = SUBSTRING(@InputString, @Index, 1)
IF @Char IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&','''','(')
IF @Index + 1 <= LEN(@InputString)
BEGIN
IF @Char != ''''
OR
UPPER(SUBSTRING(@InputString, @Index
+ 1, 1)) != 'S'
SET
@OutputString =
STUFF(@OutputString,
@Index + 1, 1,UPPER(SUBSTRING(@InputString, @Index
+ 1, 1)))
END
SET @Index = @Index + 1
END
RETURN ISNULL(@OutputString,'')
END
Hope this will help!!
Regards,
Nitin Sharma
Sunday, February 16, 2014
Make RDLC reports as alternate row color
Hi friends,
Today I will let you know how to make the RDLC rows as alternate colors.
Just select the row of the report in Design and press F4 , now you can see the properties.
In the BackgroundColor , click on the Expression hyperlink and write the below expression :
=iif(RowNumber(
Nothing) mod 2, "LightBlue", "LightCyan")
Thats it.. you can change the color as you need. I have taken as LightBlue and LightCyan as an example.
Thanks,
Nitin Sharma
Today I will let you know how to make the RDLC rows as alternate colors.
Just select the row of the report in Design and press F4 , now you can see the properties.
In the BackgroundColor , click on the Expression hyperlink and write the below expression :
=iif(RowNumber(
Nothing) mod 2, "LightBlue", "LightCyan")
Thats it.. you can change the color as you need. I have taken as LightBlue and LightCyan as an example.
Thanks,
Nitin Sharma
Monday, September 16, 2013
How to find 2nd,3rd,4th ..... nth largest / smallest salary in a table
Hi All ,
Just thought to share with you some simple SQL query that is used very frequently in our projects and mostly asked in interviews as well.
It is " Write a SQL Query to find the 2nd, 3rd, 4th ...........nth largest salary from a table".
Note here N , N is equal to which largest salary you want to find. Like if you want to find 2nd highest , it will be Top 1 , if you want to find 3rd highest it will be Top 2 , if you want to find 4th highest it will be Top 3 and so on........
So Here is the SQL Query to find out the 3rd largest query from a table :
Just thought to share with you some simple SQL query that is used very frequently in our projects and mostly asked in interviews as well.
It is " Write a SQL Query to find the 2nd, 3rd, 4th ...........nth largest salary from a table".
So Here is the SQL Query to find out the 3rd largest query from a table :
Similarly if you want to find the smallest salary , the above will remain same except you have to replace :
1)MAX(Salary) with MIN(Salary)
2) Order by Salary Desc with Order by Salary Asc
Here's the query to find the 2nd smallest salary from the table ...
Thanks,
Nitin Sharma
Monday, July 30, 2012
Create Circle in web page by CSS
Hi All,
This post is regarding CSS i.e how to show a CIRCLE in a web page via css .
Firstly make a .css file and add the following code into into it :
Now place a
This post is regarding CSS i.e how to show a CIRCLE in a web page via css .
Firstly make a .css file and add the following code into into it :
.circle {
border-radius:
50%;
background-color:Black;
width: 200px;
height: 200px;
}
Now place a
Saturday, February 18, 2012
Fetch / Get Current Date from SQL Server in a specific format
Hi All,
Working on Saturday is really a pain...Phew...!!!!...
I came across a requirement where you have to get a Current Date from Sql Server in the following format :
So, here is the script with the Sql Server Replace function...:
And the Result is :
Thanks,
Nitin Sharma
Happy Coding....
Working on Saturday is really a pain...Phew...!!!!...
I came across a requirement where you have to get a Current Date from Sql Server in the following format :
DD - MM - YYYY (note the hyphen in between)
So, here is the script with the Sql Server Replace function...:
Select Replace(Convert(varchar(11),Getdate(),106),' ',' - ') as 'Today'
And the Result is :
Thanks,
Nitin Sharma
Happy Coding....
Friday, February 17, 2012
Add Twitter and Facebook like Social Sites link to ASP.NET WebSite
Hi All,
Clicking on Facebook image opens the below page as a pop up:
This is my first post of the year 2012.
I came across one requirement in my recent project in which where i do have to add two share buttons for two most popular social networking sites Facebook and Twitter.
I found this HTML code to be placed in any asp.net site . Below is the code:
<a href="http://twitter.com/home?status=" target="_blank"
onclick="window.open(this.href,
this.target,'height=500px,width=400px'); return false">
<img src="Images/twitter.png" alt="Share on
Twitter" />
a>
<a href="http://www.facebook.com/connect/prompt_feed.php?&message="
target="_blank" onclick="window.open(this.href,
this.target,'height=500px,width=400px'); return false">
<img src="Images/facebook.png" alt="Share on
Twitter" />
a>
Thats it...and you are ready with the share button.
Below is the snapshot of the rendered page after click on facebook and twitter image link.
Clicking on Twitter image opens the below page as a pop up:
Clicking on Facebook image opens the below page as a pop up:
This is for sharing your own on these two networking sites but not shareing the link or any other outside matter.
Thanks,
Nitin Sharma
Happy Coding..!!!
Labels:
ASP.NET,
Javascript,
Source Code,
Technical,
Technology
Location:
Gurgaon, Haryana, India
Tuesday, December 6, 2011
Machine Key Generator for Encrypted PasswordFormat in ASP.NET Membeship
Hello Techies,
Here i found a MachineKey Generator ( generated in XML tag ) , which generates your machine key that is used in applications.
Go to this URL : http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx
Click on the button "Generate Me A Key!"
I found it when i was in need to change my PasswordFormat to "Encryted" in ASP.NET membeship.
So what you have to do is add / change the passwordFormat="Encrypted"/> and add the machine key in thetag.
So , your web.config will have settings like this.
Asp.NET membership has "Hashed" Passwordformat by default but you have to change in web.config file for "Clear" and "Encrypted" formats. (remember both format names are case sensitive).
Thanks,
Happy coding
Nitin Sharma
Here i found a MachineKey Generator ( generated in XML tag ) , which generates your machine key that is used in applications.
Go to this URL : http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx
Click on the button "Generate Me A Key!"
I found it when i was in need to change my PasswordFormat to "Encryted" in ASP.NET membeship.
So what you have to do is add / change the passwordFormat="Encrypted"/> and add the machine key in the
So , your web.config will have settings like this.
Asp.NET membership has "Hashed" Passwordformat by default but you have to change in web.config file for "Clear" and "Encrypted" formats. (remember both format names are case sensitive).
Thanks,
Happy coding
Nitin Sharma
Labels:
ASP.NET,
C#,
Technical,
Technology
Thursday, November 24, 2011
Show excel sheet data in Gridview using C#
Hi All,
This post show how you can show data of Microsoft Excel Sheet inside a ASP.NET gridview.
The excel sheet in this example is generated by exporting the Northwind Database's Customers table . I have placed the excel sheet in my D:\ directory and named it as "Test".
The excel sheet looks something like this :
Now on a web page take a ASP.NET GridView Control and and on the Page_load event write this code :
This post show how you can show data of Microsoft Excel Sheet inside a ASP.NET gridview.
The excel sheet in this example is generated by exporting the Northwind Database's Customers table . I have placed the excel sheet in my D:\ directory and named it as "Test".
The excel sheet looks something like this :
Now on a web page take a ASP.NET GridView Control and and on the Page_load event write this code :
string F1Name = "D:\\Test.xls";
string
CnStr = ("Provider=Microsoft.Jet.OLEDB.4.0;"
+ ("Data Source="
+ (F1Name + (";"
+ "Extended Properties=\"Excel
8.0;\""))));
DataTable
DT = new DataTable();
OleDbDataAdapter
DA = new OleDbDataAdapter("Select * from [Customers$]", CnStr);
Response.Write("File
Accessed!!!!");
try
{
DA.Fill(DT);
GridView1.DataSource = DT;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Run the WebPage and see the result as:
Hope it will be useful.
Thanks,
Nitin Sharma
Wednesday, November 23, 2011
Apply Custom Style to Gridview using Style class and ApplyStyle method
Hi,
In this post I will apply my own style to the Gridview Control.
1) Add a new page say "GV.aspx" in your asp.net website/web application.
2) Drag and drop Gridview and a button control from the toolbox on the page.
3) Bind the Gridview on page load event. I have used LINQ to SQL In this example for binding the Gridview.
The database used is Northwind. The name of LINQ class here is DB and I have added two tables Product and Category.
In this post I will apply my own style to the Gridview Control.
1) Add a new page say "GV.aspx" in your asp.net website/web application.
2) Drag and drop Gridview and a button control from the toolbox on the page.
3) Bind the Gridview on page load event. I have used LINQ to SQL In this example for binding the Gridview.
The database used is Northwind. The name of LINQ class here is DB and I have added two tables Product and Category.
DBDataContext db = new DBDataContext();
protected void Page_Load(object
sender, EventArgs e)
{
// Simple
LINQ query
var
products = from p in
db.Products
where
p.Category.CategoryName == "Beverages"
select
p;
GridView1.DataSource = products;
GridView1.DataBind();
}
Note that I have instantiated DataContext class outside the Page Load event making it Global to the page.
4) Now I will create a new style from the Style class and apply it to the Gridview using ApplyStyle() method.On the button Click Event add this piece of code:
protected void btnStyle_Click(object
sender, EventArgs e)
{
Style
myStyle = new Style();
myStyle.ForeColor = System.Drawing.Color.Red;
myStyle.BackColor = System.Drawing.Color.Turquoise;
myStyle.Font.Bold = true;
myStyle.BorderStyle = BorderStyle.Solid;
GridView1.ApplyStyle(myStyle);
}
5) Run it and click on the button and see the output.Below is the screenshot showing before and after applying style.
Gridview before applying style
Gridview after applying style (Click on Apply Style Button)
That's it..!
Thanks,
Nitin Sharma
Location:
Gurgaon, Delhi, India
Subscribe to:
Posts (Atom)











