Skip to main content

Posts

Showing posts from 2010

Radio Button in Grid View

I had use radio button in grid view into my recent development. Radio button Group problem in Grid view I found that radio button is not create group when they are render on client side into grid rows because of the automated id and name creation of the asp.net. Radio button checked property problem in Grid view on server side code One more problem I found that when we iterate through grid view rows on server side code. I can find the radio button using the rows[0].findcontrol('id') method but its always give me a checked value false. Following is solution I applied into my development to get out of this tow. I replace Radio button server control with the HTML input control with type radio. < asp:RadioButton ID ="RadioButton1" runat ="server" /> < input type ="radio" runat = "server" ID = "radio1" class = "rbclass" value =' <% # Eval("columen name") %> ' />

ExecuteScalar function with Generic Data Type

Here is the static function which will Generic Data Type to get the scalar value from the query passed to the ExecuteScalar function of the SqlCommand object. You have to pass the query and the connection string as parameter to it. public static T ExecuteScalar<T>( string query, string strConnection) {             SqlConnection con = new SqlConnection (strConnection);             SqlCommand sc = new SqlCommand ();             sc.CommandText = query;             sc.Connection = con;             try             {                 con.Open();                 return (T)(sc.ExecuteScalar());             }             catch ( Exception ex)             {                 throw ex;             }             finally             {                 con.Close();                 con.Dispose();                 sc.Dispose();             }         }

Convert Generic List to CSV

In my recent development with c#, I have to code for the functionality to Convert one Generic list of class XYZ to CSV downloadable File with dynamically suppress some of the column and different descriptive headers then the properties name for the column. So I develop one Generic function which will convert List to CSV and return the string, which will then wrapped to Http Response to available as downloadable file. Here is a Function which will convert List of Generic type T to CVS format string with 2 arguments. First Argument is List of objects to be converted into CSV and second is the 2 dimensional string array with the name of properties of object to be include in conversion with the Header Text for that properties to use while it is converting into CSV. private static string ListToCsv( ref List <T> list, string [,] HeaderAndColumns)         {             if (list == null || list.Count == 0) return "" ;             Type t = typeof (T);             int

How to set culture of asp.net page

Here I show you how to set the culture of your asp.net page through code. To do that you have to over ride InitializeCulture mthod of page. And Set the UICultuer and Culture properties of page for the specified culture like 'en-US', 'en-GB' etc. For example this . UICulture = “en-GB” ; this . Culture = “en-GB” ; This set you page culture to English UK (GB for grate brighten). Now all you need is list of cultures available in .net to get that we use following code which will retrieve the list of culture available with the .net. CultureInfo [] cultures = System.Globalization. CultureInfo .GetCultures( CultureTypes .SpecificCultures); cultures = cultures.OrderBy(c=>c.EnglishName).ToArray(); Now you can bind these values with the drop down list. foreach ( CultureInfo c in cultures) {     ddlCulture.Items.Add( new ListItem (c.EnglishName + " : " + c.NumberFormat.CurrencySymbol, c.Name)); } Get the selection from user and set the Session va

DNN Modules - Google Analytic Dashboard

This is my first DNN related post in this post. Here is a Google Analytic Dashboard DNN Module which contain following sub modules. Visitors Overview World Map Overlay Traffic Sources Overview Click here to download Installable and source.  After installing the module you will find listed modules into your module drop down list.Drop module on to the page and then done following setting through setting page of the module. Google Analytic Email id - your Google analytic accounts email id. Google Analytic password - password for the analytic account. Google Analytic Profile id - this is your Google analytic profile id for which you want to display charts. Width and Height - optional. Note : For the detail of how to get profile id click here and see the bottom parts of the post. Save this setting and enjoy this module. There Date range selector which set the date range for the charts, set them to your desire period and click on apply. you can see the result for that dat

Google Analytic Helper Class ..

Google analytic is very powerful and handy utility provided by the Google to track your web site traffic from all over the word. To use this Google analytic with our asp.net page we have to put one java script code into the page based on the WebPropertyId of the analytic profile from which we track our site. Following are the some ready made methods of helper class which help you to play with google analytic into your asp.net page Please download following assembly to use the helper class methods Download - "Google Analytics Desbord Controls.dll" 1) getTrackerCode GADCAPI.GADCAPIHelper . getTrackerCode( string WebPrppertyId) This method return the java script which used to place into the page to activate google analytic tracker on that particular page. Output: var gaJsHost = ((""https:"" == document.location.protocol) ? ""https://ssl."" : ""http://www.""); document.write(unescape(""%3Cscript src

Google Analytic Dashboard Controls

"Google Analytic Dashboard Controls" is costume controls library which contain ASP.NET costume controls which generate different types of charts like Google analytic dashboard using Google analytic data export api. Its include following controls. Visitors overviews Word map overview Traffic source overview Content overview Followings are the images of the resulting graphs using them Visitors Overview Traffic Source Overview Word Map Overview Content Visits Overview To use this controls into your ASP.NET projects follow the below steps. 1. Download "Google Analytics Desbord Controls.dll" 2. Add reference of "Google Analytics Desbord Controls.dll" to your project. 3. In toolbox add controls by Right Click -> Choose Items -> browse dll. 4. Now Drag and drop control to your .aspx file. 5. Set Properties GAEmailAddress to your Google Analytic account email id, GAPassword to password , GAProfileId