Geeks With Blogs
Carmel's Blog Independent Software Professional November 2008 Entries
Adding Button Column to DataGridView
There are a lot of cases we need to add new button column in our DataGridView so we can perform custom logic for each row. For instance add to shopping card a product by pressing on ADD button in the DataGridView. One way to perform this task is to add template column to the DataGridView that contains a button bounded to the Product ID Field and Command Event: 1. Add Template column: 2. Enter to Edit Mode of the new Template Column and add command button: 3. Bind the button CommandArgument Property ......

Posted On Tuesday, November 11, 2008 6:32 AM

using using (free connection)
Considure the following code: public static DataSet GetCity() { SqlConnection connection = GetConnection(); SqlDataAdapter adataper = new SqlDataAdapter("select * from City", connection); DataSet City = new DataSet(); adataper.Fill(City, "City"); return City; } This function loads the city table from the database to a dataset, the problem with code is: 1. connection object and adapter object both had a Dispose method but it's not executed, 2. close connection method is not executed. Why it's good ......

Posted On Tuesday, November 11, 2008 6:21 AM

Retreiving Identity after insert to table
The following code enables you to retrieve identity after insert to table in the database: string connectionString = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True"; string commandText = "Insert into tblID (Name) values (N'name') SELECT SCOPE_IDENTITY()"; object id; using (SqlConnection connection = new SqlConnection(connectionStr... { using(SqlCommand command = new SqlCommand(commandText, connection)) { command.CommandType = CommandType.Text; connection.Open(); id = command.ExecuteScalar(); ......

Posted On Tuesday, November 11, 2008 6:20 AM

Loading List Controls
ASP.NET contain number of list controls like: DropDown List Control, List Box Control and other. These controls are derived from the List Control Class, the List Control Class is an abstract class that expose common interface for the derived controls. One of the common tasks that we do with these control is loading them from data source, considure the following code: DropDownList1.DataSource = GetDataSource; DropDownList1.DataMember = "MemberName"; DropDownList1.DataValueField = "Field Name"; DropDownList1.DataTextField ......

Posted On Tuesday, November 11, 2008 6:18 AM

End Request Agrs Object
Script Manager Object allows developers to add AJAX Capabilities to ASP.NET page, this object contains end request event in the client side, this event fired when the AJAX request completed. AJAX request may complete successfully, with errors or timeout. End Request event have args object, the args object can be used to examine the request completion. The args object contains the following members: args._errorHandled - Boolean property indicates whether you handled the error or not. args._response ......

Posted On Tuesday, November 11, 2008 6:17 AM

Adding Button Column to DataGridView
There are a lot of cases we need to add new button column in our DataGridView so we can perform custom logic for each row. For instance add to shopping card a product by pressing on ADD button in the DataGridView. One way to perform this task is to add template column to the DataGridView that contains a button bounded to the Product ID Field and Command Event: 1. Add Template column: 2. Enter to Edit Mode of the new Template Column and add command button: : 3. Bind the button CommandArgument Property ......

Posted On Tuesday, November 11, 2008 5:44 AM

Copyright © Carmel Halabe | Powered by: GeeksWithBlogs.net