Search This Blog

Wednesday, October 24, 2012

How to add HyperLink Column to Telerik RadGrid Code Behind

Telerik > RadGrid > GridHyperLinkColumn





Each row in a Hyperlink column will contain a predefined hyperlink. This link is not the same for the whole column and can be defined for each row individually.

DataNavigateUrlFields: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.

DataNavigateUrlFormatString: Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will form the url of the windwow/frame that the hyperlink will target.
Example:
Add hyperlink column to RadGrid programmatically

RadGrid grd = new RadGrid();
GridHyperLinkColumn linkColumn = new GridHyperLinkColumn();
string[] fld = { "id" };
linkColumn.DataNavigateUrlFields = fld;
linkColumn.DataNavigateUrlFormatString = "Default.aspx?ID={0}";
linkColumn.HeaderText = "Id";
grd.Columns.Add(linkColumn);









DataTable.Select Method (String) c#

C# > Data   > DataTable > Select

DataTable Select method gets an array of all DataRow objects that match the filter criteria.
If the column on the filter contains a null value, it will not be part of the result.

Example:

private void FilterDataTable(string filter)
{
    DataTable table = DataSet1.Tables["Person"];
    DataRow[] foundRows;

    // Use the Select method to find all rows matching the filter. Sample: filter = "name = 'dan' "
    foundRows = table.Select(expression);
    for(int i = 0; i < foundRows.Length; i ++)
    {
        Console.WriteLine(foundRows[i][0] );
    }
}






Wednesday, October 17, 2012

How to exit for C#

C# > Statements > break

How to exit for C#? The answer is break.
The break statement terminates the closest enclosing loop or switch statement in which it appears. Control is passed to the statement that follows the terminated statement.

Example:

for (int j = 0; j < list.Count; j++)
{
    if (j==5)
       break;
}





Friday, October 12, 2012

Transaction SQL Server

SQL Server

BEGIN TRANSACTION

BEGIN TRANSACTION represents a point at which the data referenced by a connection is logically and physically consistent. If errors are encountered, all data modifications made after the BEGIN TRANSACTION can be rolled back to return the data to this known state of consistency. Each transaction lasts until either it completes without errors and COMMIT TRANSACTION is issued to make the modifications a permanent part of the database, or errors are encountered and all modifications are erased with a ROLLBACK TRANSACTION statement.

ROLLBACK TRANSACTION

Rolls back an explicit or implicit transaction to the beginning of the transaction, or to a savepoint inside the transaction. You can use ROLLBACK TRANSACTION to erase all data modifications made from the start of the transaction or to a savepoint. It also frees resources held by the transaction.

COMMIT TRANSACTION

Marks the end of a successful implicit or explicit transaction. If @@TRANCOUNT is 1, COMMIT TRANSACTION makes all data modifications performed since the start of the transaction a permanent part of the database, frees the resources held by the transaction, and decrements @@TRANCOUNT to 0. If @@TRANCOUNT is greater than 1, COMMIT TRANSACTION decrements @@TRANCOUNT only by 1 and the transaction stays active.






Example

begin transaction

update table1
set field1='a'

if @@ERROR <> 0
begin
 rollback transaction
 RAISERROR ('Error table1',16,1)
 return -1
end


update table2
set field3='a'

if @@ERROR <> 0
begin
rollback transaction
RAISERROR ('Error table2',16,1)
return -1
end

commit transaction

Tuesday, October 9, 2012

Max upload file size in ASP.NET

ASP.NET > MaxRequestLength

The MaxRequestLength property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service attacks that are caused by users who post large files to the server.

The default value is 4096 KB (4 MB).

Example: Set max size up to 64 MB in web.config

<httpRuntime
maxRequestLength="65536"
/>





Monday, October 8, 2012

IndexOf c#

C# > String > IndexOf

Reports the zero-based index of the first occurrence of the specified string in another string.

Index numbering starts from zero.

The zero-based index position of value if that string is found, or -1 if it is not.

This method performs a word (case-sensitive and culture-sensitive) search using the current culture. The search begins at the first character position of this instance and continues until the last character position.

Example:

string ast_name = valuePath;
int poz = ast_name.IndexOf("http");
if (poz >-1) // found "http"
   ast_name = ast_name.Substring(poz,ast_name.Length-poz);





Friday, October 5, 2012

Changing the size of Telerik RadComboBox DropDown

Telerik > RadComboBox > ComboBoxElement > DropDownWidth 


this.radComboBox1.ComboBoxElement.DropDownWidth = 200;
this.radComboBox1.ComboBoxElement.DropDownHeight = 600;





Thursday, October 4, 2012

Browse all rows and values RadGridView - Win Forms

Telerik > RadGridView > Browse all rows and values

Example:

C# Code
            for (i = 0; i <= RadGridView1.Rows.Count; i++)
            {
                for (j = 0; j <= RadGridView1.Columns.Count; j++)
                {
                    dynamic di = RadGridView1.Rows(i).Cells(j).Value;
                }
            }
            //or
             foreach (GridViewRowInfo _row in RadGridView1.Rows)
            {
                foreach (GridViewColumn _column in RadGridView1.Columns)
                {
                    dynamic di = _row.Cells(_column.Name).Value;
                }
            }

VB.NET Code

For i = 0 To RadGridView1.Rows.Count
  For j = 0 To RadGridView1.Columns.Count
   Dim di = RadGridView1.Rows(i).Cells(j).Value
  Next
Next
'or
For Each _row As GridViewRowInfo In RadGridView1.Rows
  For Each _column As GridViewColumn In RadGridView1.Columns
    Dim di = _row.Cells(_column.Name).Value
  Next
Next






How to set time to RadTimePicker Programmatically (ASP.NET)

Telerik > RadTimePicker > Set time

StartTime represents the starting time of the clock
EndTime represents  the time of the last clock item

Example : Set time  to RadTimePicker  code behind


RadTimePicker1.SelectedDate = DateTime.ParseExact("12:00", RadTimePicker1.TimeView.TimeFormat, null); // set default time

RadTimePicker1.TimeView.StartTime  = new TimeSpan(8, 60, 0); //start time
RadTimePicker1.TimeView.EndTime =  new TimeSpan(17,60, 0); // end time





OLAP

Database > OLAP





Short for Online Analytical Processing, a category of software tools that provides analysis of data stored in a database. OLAP tools enable users to analyze different dimensions of multidimensional data. For example, it provides time series and trend analysis views. OLAP often is used in data mining.

The chief component of OLAP is the OLAP server, which sits between a client and a database management systems (DBMS). The OLAP server understands how data is organized in the database and has special functions for analyzing the data. There are OLAP servers available for nearly all the major database systems.

Microsoft SQL Server Analysis Services is part of Microsoft SQL Server, a database management system. Microsoft has included a number of services in SQL Server related to business intelligence and data warehousing. These services include Integration Services and Analysis Services. Analysis Services includes a group of OLAP and data mining capabilities.

Oracle Essbase is the industry-leading multi-dimensional online analytical processing (OLAP) server, providing a rich environment for effectively developing custom analytic and enterprise performance management applications. By leveraging its self-managed, rapid application development capabilities, business users can quickly model complex business scenarios. For example, line-of-business personnel can simply and rapidly develop and manage analytic applications that can forecast likely business performance levels and deliver "what-if" analyses for varying conditions. Oracle Essbase supports extremely fast query response times for vast numbers of users, large data sets, and complex business models.

Analysis Services tutorial. Creating OLAP cube. Introduction to data warehouse