Showing posts with label Tips n Tricks. Show all posts
Showing posts with label Tips n Tricks. Show all posts

Saturday, April 21, 2012

Left or Right alignment in Gridview Columns

When we work with Grid-view we need to make left or right or centered alignment on column values according to their Datatype.For example we have to make right aligned all money values and character values to be left aligned. To do this just embed column within table like given example -:

 <asp:TemplateField HeaderText="Debit">
          <ItemTemplate>
                    <table align="right"  ><tr><td>
                                <asp:Label ID="lblDebit" runat="server" Text='<%# Bind("Debit") %>'></asp:Label>
                    </td></tr></table>
          </ItemTemplate>
 </asp:TemplateField>

Hope you'll get it. Enjoy coding.

Monday, March 26, 2012

Show Value upto Two Decimal Places in Gridview

Show money or float values upto two decimal places using 
String.Format in Gridview.
 
<%# String.Format("{0:f2}",DataBinder.Eval(Container.DataItem,"Rate")) %>
 or
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Amt","{0:f2}")  %>'></asp:Label> 
 
Example :  
<asp:TemplateField  HeaderText="Rate">
<ItemTemplate>
   <table align="right" style="text-align: right"><tr><td align="right">
    <asp:Label ID="lblRate" runat="server" 

Text='<%# String.Format("{0:f2}",DataBinder.Eval(Container.DataItem,"Rate")) %>' ></asp:Label>
   </td></tr></table>
</ItemTemplate>
</asp:TemplateField>

Friday, December 2, 2011

Get Connection String Information without any help of Database


Today I m going to show you how to get the connection string value without any help of sql server and visual studio.
Step 1-: Create a blank text document, save it as all files and give file name as “a.udl”.
 Step 2-: Now double click it.It will open as given screen shot.

Step 3-: Select database provider in provider tab and click next.
Step 4-: Then in Connection tab provide all necessary details and finally click ok.
 Step 5-: Now open your udl file in text format i.e. notepad where you wil find your Connection String.



Friday, November 11, 2011

Menu Control Not Working Properly On Every Browser

Browser Compatibility Code 
Paste below code in your page_load event of page or master page and then test it on mac safari. Its working fine
if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
  {
            Request.Browser.Adapters.Clear();
  }