Monday 30 December 2013

ASP.Net - How to Format Date in Bind Statement inside a label

Watch this example on YouTube



<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Bind("BirthDate","{0:MMM dd, yyyy}") %>'></asp:Label>

</ItemTemplate>

ASP.NET 2013 - How to bind multiple data to itemtemplate label in gridview

Watch this example on YouTube




 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
            <Columns>
                 <asp:TemplateField HeaderText="Customer" SortExpression="CustomerID">
                     <ItemTemplate>
                         <asp:Label ID="Label1" runat="server" Text='<%# String.Format("{0} {1} {2} {3} {4}" ,"(", Eval("CustomerID") , "-" ,Eval("CustomerName"), ")") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
            </Columns>
        </asp:GridView>

MS Sql 2013 - How to fix error Must declare the scalar variable - another example

Replace

Declare @CustomerIDs VARCHAR(50) = '1,2'

declare @CustomerTbl table(Stat nvarchar(300))

insert into @CustomerTbl

select DISTINCT CustomerID

from CustomerMaster

WHERE ','+ Convert(varchar(50),@CustomerIDs) +',' like '%,'+ Convert(varchar(50),CustomerID) +',%'

Select * FROM CustomerMaster INNER JOIN

@CustomerTbl ON CONVERT(VARCHAR(300),CustomerID) = @CustomerTbl.Stat

With

Declare @CustomerIDs VARCHAR(50) = '1,2'

declare @CustomerTbl table(Stat nvarchar(300))

insert into @CustomerTbl

select DISTINCT CustomerID

from CustomerMaster

WHERE ','+ Convert(varchar(50),@CustomerIDs) +',' like '%,'+ Convert(varchar(50),CustomerID) +',%'

Select * FROM CustomerMaster INNER JOIN

@CustomerTbl ct  ON CONVERT(VARCHAR(300),CustomerID) = ct.Stat

MS SQL 2013 - How to fix error - Must declare the scalar variable

Watch this example on YouTube



Replace

DECLARE @Customer VARCHAR(20)

SET @Customer = '1'

Declare @sql varchar(max)

Set @sql = 'SELECT * FROM CustomerMaster '

Set @sql = @sql + 'WHERE CustomerID =  @Customer'

Execute(@sql)

With

DECLARE @Customer VARCHAR(20)

SET @Customer = '1'

Declare @sql varchar(max)

Set @sql = 'SELECT * FROM CustomerMaster '

Set @sql = @sql + 'WHERE CustomerID = ' +@Customer

Execute(@sql)

Sunday 29 December 2013

How to import contact from BlackBerry to Samsung Galaxy S4 in a few seconds

Watch this example on YouTube

ASP.Net - How to disable days in Calendar, change color of disabled days, strike out

Watch this example on YouTube



protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

{
 
if (e.Day.Date < DateTime.Now.Date)

{
 
                 
   e.Day.IsSelectable = false;

   e.Cell.ForeColor = System.Drawing.Color.Red;

   e.Cell.Font.Strikeout = true;


}

}
 

Microsoft Visual Studio 2013 - How to switch between tabs in code editor using key shortcuts

Watch this example on YouTube


use Ctrl+Shift

Monday 16 December 2013

C# - How to fix error - 'StringBuilder' could not be found

Watch this example on YouTube


You may receive this error if you translated VB.NET code into C# using some online translator

Error 1 The type or namespace name 'StringBuilder' could not be found (are you missing a using directive or an assembly reference?) C:\Users\livingroomadmin\Documents\Visual Studio 2013\Projects\WebApplication1\WebApplication1\WebForm1.aspx.cs 16 13 WebApplication1

to fix it simply add

using System.Text

C# - How to fix error - Newline is constant

Watch this example on YouTube

Replace
text = text.Replace("\\", "\");
with
text = text.Replace(@"\\", @"\");

ASP.NET - Grid View - How to remove grid header



Replace
<asp:GridView ID="GridView1" runat="server" ></asp:GridView>
With
<asp:GridView ID="GridView1" runat="server" showheader="false" ></asp:GridView>

ASP.NET - CSS - How to apply 2 classes to control

Wath this example on YouTube.

Example that shows how to apply multiple css classes to one div
I have 2 classes in my css

.DefaultFontColor {

color: red;

}
 
.DefaultFont {

font-size: 20px;




}

then in html
<div class="DefaultFont DefaultFontColor">


some text
 
</div>

Thursday 5 December 2013