Posts

Showing posts from June, 2012

Decide Cursor Type and Lock Type based on CRUD Operation

Normally when we do the addition and deletion of record in the ADODB,cursor type and lock type will be changed.So we need to be very careful while adding and deleting a record using the record set object.So for this I have done a sample on addition only. 1. When we want to add using the record set object we need to pass the Cursor Type and Lock Type as     ADODB.CursorTypeEnum.adOpenDynamic    ADODB.LockTypeEnum.adLockOptimistic 2. By default, ADO record sets are opened with a lock type of adLockReadOnly, which does not allow additions and deletions. 3. To allow additions and deletions, open the record set with a lock type of either adLockOptimistic or adLockPessimistic To Solve this we need change the code like this Dim recordSetObj As New ADODB . RecordSet recordSetObj . Open ( "select * from students" , "Your Connection Object" , ADODB . CursorTypeEnum . adOpenDynamic , ADODB . LockTypeEnum . adLockOptimistic ) If Not recordSe

Get the Clicked Cell Value and Column Name of GridView in ASP.NET

Image
Normally we find the requirement to get the selected Cell Clicked Value .In rare cases we need to find the Column Name and Index of the Cell clicked in the GridView. This is some how tricky work to get the Column name and index also.We can do this in many ways . We must be very much thankful to the jQuery contributors for such beautiful lightweight,fast and concise Library. Really this is very good  we can't iterate the table loop to the clicked cell value. With a Single we can get the clicked Value.Look at this line of Code $('#gv>tbody>tr>td').text(); For this requirement I have taken a grid which i have given a static datasource. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AddData(); } } public void AddData() { try { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(Int32)); dt.Col

Convert DataSet or DataTable to XML

Normally we face this problem where we have lots of data to convert into XML file from DataSet or DatTable  .Because XML file is readable by all languages. Here I have some sample Snippet for Writing the DataSet or DataTable to XML format. DataSet ds = new DataSet(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[ "CON" ].ConnectionString)) { con.Open(); string Query = "select col1,col2 from table " ; SqlDataAdapter da = new SqlDataAdapter(Query, con); da.Fill(ds,"TableName"); ds.Tables[ "TableName" ].WriteXml( "XML File Path" ); } Hope this help you :-) Any Suggestion s on this article are welcome :-)

jQuery to Validate password and confirm password

Image
This article is mainly focused on the validating the password and Confirm password using Client Side Scripting " jQuery ". Normally we have password and confirm password in the regsitration page where we need to validate the password and confirm password. This can also be done using the compare validator also in Asp.Net. In this demo I have taken two textboxes where i set the textmode as "password".Now in the button click I am validating the both fields has same value or not. HTML Markup: Code : Here I have written like if both the values are same then excute the server code as "return 1==1"  :-) which means execute the server code. Any suggestion on this article are welcome . Hope this may help :-)

Swapping of ListBox Items using jQuery

Image
The interchanging of Items of one list-box to other list-box is done in this Swapping of List-box Items .Here the swapping is done in the Client Side using jQuery.For Swapping the Items  I took  two Array lists . Initially I have filled the two array lists with the list boxes data.Now I have written a Common Method to swap the Items from one list box to other. HTML Markup: <div> <asp:ListBox runat="server" ID="lstbx1"> <asp:ListItem Text="text1" /> <asp:ListItem Text="text2" /> <asp:ListItem Text="text3" /> <asp:ListItem Text="text4" /> </asp:ListBox> <br /> <asp:ListBox runat="server" ID="lstbx2"> <asp:ListItem Text="text5" /> <asp:ListItem Text="text6" /> <asp:ListItem Text="text7" /