Wednesday, July 27, 2011

GridView RowDataBound or RowCommand

The best place to check or bind controls can be done in RowDataBind Event of GridView.

It can also be done in RowCommand event handler, but during postback there are chances data be lost. I was attaching javascript to a button with another value collected from a databound control, and during postback the data collected and passed to javascript was lost.




Thursday, July 21, 2011

Tuesday, July 19, 2011

Configuring Visual Source Safe in Visual Studio IDE

In the Tools -> Options -> Source Control, we should be able to select the Source Control here "Microsoft Visual SourceSafe" or any other provider.

Sometimes the in “Current source control plug-in:”, the only choice available may be “none”. In that case we must manually register the dll.

a) In that case close all Visual Studio instances.

b) Browse to your VSS6\win32 directory and run:
“regsvr32 ssscc.dll”

This would register the library and make VSS 6.0 available in the Visual Studio IDE, when we reopen it.

Monday, July 11, 2011

Using Windows User Role with Active Directory

To use Active Directory permissions in a ASP.NET web application,

1) In WEB.CONFIG, enable windows authentication
< authentication mode="Windows" / >

2) In IIS, enable Windows Authentication and disable Anonymous authentication

Enter Key Default Submit Button

If there is only one button in a WEB FORM, pressing ENTER will enable the default submit button.

If there are more than one buttons in a web form, then we can define the default submit thru DEFAULTBUTTON property either in the FORM  or with an PANEL.

1<form defaultbutton="btnSubmit" id="form1" runat="server"
</form >

2) <panel defaultutton="btnSubmit" id="pnlFirst" runat="server"></panel>

Sunday, July 10, 2011

Connecting MySQL Database with .NET Applications

We can do this many ways,


1) In the MySQL site there is a library to connect to MySQL.
       http://www.mysql.com/products/connector/

Download and install this library. Infact we need only the MySql.Data.dll added as a reference to the project. Then we can work like rest like the ado.net providers with MySQL Connection, MySQLCommand, MySQLDataAdapter and MySQLDataReader

Imports MySql.Data.MySqlClient
Public Sub LoadMySQLDB()

Dim myConnection As MySqlConnection
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
Dim strSQL As String


myConnection = New MySqlConnection("server=localhost; user id=user1; password=password; database=mydatabase; pooling=false;")


strSQL = "SELECT * FROM mytable;"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, "mytable")

MySQLDataGrid.DataSource = myDataSet
MySQLDataGrid.DataBind()


End Sub

 2) Using OLEDB we can connect to MySQL
3) Using ODBC also we can connect to MySQL.

Friday, July 8, 2011

In GridViewDelete Event KEY values are empty

In the DELETEROWEVENT, the values returned is empty, it appears that e.Keys and e.Values are only populated if gridview.IsBoundUsingDataSourceID.

A possible resolution

int groupId = (int)GridView1.DataKeys[e.RowIndex].Value;