Today I would like to share gridview edit, update and delete a row. Following I have described the some gridview event and how to handle this event. Edit: protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; // fetch and rebind the data. GridBind(); } Cancel edit: protected void GridView1_RowCancelingEdit(object sender, GridV...
First of all some basic operations that might you need to do when you play with dropdown. 1. Add an option to list: $("<option value='0'>Select</option>").appendTo("#ddlCategory"); 2. Remove all the Options from drop down: $("#ddlCategory> option").remove(); 3. Get the selected item Text: $("#ddlCategory option:selected").text(); 4. Get the selected item Value: $("#ddlCate...
Today I need to make changes in trigger but I forgot the name of trigger and associated table with it. So quickly find out the list of triggers associated with the tables in a database, I used following query. USE [YourDatabaseName] SELECT [Name] AS TriggerList, OBJECT_NAME(parent_id) AS TableList, create_date AS CreatedDate, modify_date AS ModifiedDate FROM sys.triggers ORDER BY [Name] ...
Here I discuss that how to implement modal popup in different data control like datalist and repeater. To show the modalpopup in datalist/repeater we have to use the item command event of respective control. Data control: <asp:DataList ID="dlst" runat="server" DataKeyField="ID" OnItemCommand="dlst_ItemCommand" > <HeaderTemplate> </HeaderTemplate> <ItemTemplate> &l...
To find that which control caused postback, the following example might help you. I am giving example on page load event when postback takes place. protected void Page_Load(object sender, EventArgs e) { //on every postback you can print the ID of the control which caused postback if (IsPostBack) { Control ctl = GetPostBackControl(Page); if (ctl != null) Response.Write(ctl.ID); } } //meth...
SQL Server got hanged when we try the enable service broker. So to get rid of this you have to follow these steps: First of all kill all the connections. After that changed DB mode into single user ALTER DATABASE database_name SET SINGLE_USER 3. Enable the broker ALTER DATABASE database_name SET ENABLE_BROKER 4. Finally set DB mode to multi user ALTER DATABASE database_name SET MULTI_USE...
To make the default submit button for enter key, we have to use the default key property of Form tag or panel control. I have given the example that describe how to implement it in different scope depends on your actual need. Here goes some code snippet <form id="form1" runat="server" defaultbuton="btnSubmit"> <asp:Button ID="btnSubmit" runat="server"/> </form> <asp:...
This exception generally comes when you have bind the datalist/drop down(or some other datacontrol like gridview,repeater etc.) at page load. When you click on button of datalist or drop down selected index is fire then every time your datalist/drop down populated. Because when an event raise(by the selected index change/buton click) a postback happen and page load call. So to avoid this...
I have faced a abnormal behaviour of modal pop up when used it with update panel. I have used five modal up in a single page and show modal popup in different condition. (not on a click of button) So I used a common dummy button which is visible false.(because we cannt leave the TargetControlID of popup extender.) Its working fine untill I havent enclosed with in update panel. But when I...
I have seen that lot of my friends having problem in implementing the autoextender. so that i have tried to describe that how to implement it.it may make easier to implement autoextender. Step1:Add required controls Add a text box from your toolbox. Add a autoextender and set the TargetControlID of it by setting the id of above textbox.for eg. <asp:TextBox ID="txtname" runat="server"/...
Before start the string manipulation.first of all we take a review of String class in c#. System.String class String class is a sealed class and defined as "sequential collection of System.Char objects." string vs String string is used to represent text and it is sequential collection unicode characters. String is used to represent string and it is sequential collection of System.Char ob...
Here I discuss the different formats of datetime. most of us facing this format relating issues during work with datetime. so these format may help u to display the date time format as we want . and it also help to reduce chances of exception. To get the system date and time separately in c# .just use the for date only: DateTime.Now.ToShortDateString(); for timeonly: DateTime.Now.ToShort...
A Service Reference is the same as a Web Reference. that is, you can add an ASMX web service as a reference and it will generate your proxies/etc. just like Add Web Reference did. 1) Right click References and click 'Add Service Reference' 2) In the Add Service Reference dialog click Advanced 3) In the Advanced Dialog click 'Add Web Reference' 4) Continue as you normally would for an asm...
Couple of month ago I had worked on e-commerce site, where I have to validate the credit card number. I have described some dummy credit card number by which you can test . 1. Master Card : 5431-1111-1111-1111 master card have 16 numbers starting with 5. 2.Visa : 4111-1111-1111-1111 or 4111-1111-1111-1 Visa have 13 or 16 numbers starting with 4 3: American Express : 341-1111-1111-1111 or...
I have used a Tinymce editor on a page and placed a required field validator to validate textarea. When I click the button at first time, it was gives a validaion error message even field was not empty, but at second time it submitted succesfully. Then I was tried some code which has solved my issue. The following describes how to use a validator along side TinyMCE to validate the conten...
Today, I would like to share that how to call a javascript code at aspx.cs side when we use updatepanel. Because when we used the update panel then asynchronous request goes to server. So that we have to register the script to the script manager and then it works perfectly. Please note that we have to register with scriptmanager not with scriptmanager1 or something else. Eg. protected vo...
How to send the email through asp.net is very usefull in every web application.so that i want to give some code by which you are easily send mail. Email sending through asp.net is described below: public void sendMail(string email, string name, string Password) { try { string from = " xyz@abc.com "; string MailTo = email; string title = "Email title"; string sBody = "Dear <b>" + na...
I want to share that, How to upload a file or an image through asp.net. First of you have to take a file upload control for browsing the file and button for uploading it at specified location. <asp:FileUpload ID="image_upload" runat="server" /> <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" /> after that you have write following functions fo...
Today I have learnt one thing that will help you too. so that I want to share this to you as usual. So my task is to delete the row from repeater on the basis of two parameters ASPX Page : <asp:Button ID="button1 Text="Accept" CommandName="Accept" CommandArgument = '<%# Eval("ID1") + "," + Eval("ID2") %>' runat="server" /> ASPX.CS : protected void rpt1_ItemCommand(object sour...
I have faced problem while passing the multiple querysring parameters from the hyperlink column of datalist.I have spend time for this and ultimately I have found right one. So i would like describe that how it can possible: <asp:DataList ID="dlst1" runat="server" > <ItemTemplate> <a Href='<%#"page1.aspx?first=" + Eval("First") + "& second=" + Eval("Second") %>' ...
I have faced this exception several times and spent lot of time to solve this problem, Basically when I was beginner in progamming. I think this error comes in different conditions, but iwould like to discuss the common reasons which i have faced during my programming life. Scope Declaration: When we used a variable which scope defined locally and used like global.Suppose we define a var...
Few days back I have faced problem regarding sending multiple value in single parameter (Like. 1,2,3..) to the stored procedure and on the basis of that, I have to use the result of this stored procedure. I have spend couple of days for solving this issue.so I want to share this to you. First of all I have taken a parameter of type string which contains the value like "1,2,3" .after that...
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address:
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18