Skip to main content

Posts

Showing posts from November, 2012

Complete Code for Data List & Button Click Event

Dear All Here is a code for datalist with image / link button control. Also you can get the value of record id when you click on the button under the datalist item Your Ascx file  <asp:DataList ID="DataList1" runat="server" Width="100%" OnItemCommand="Your_Function_Name" >   <ItemTemplate>  <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="/DesktopModules/Tarahum Admin CP - Add New Case/images/deleteNew.png" CommandName="del"   CommandArgument='<%#Eval ("recID") %>' />   </ItemTemplate> Note: Command Arugement is the value that you need to pass on button click and command name is a unique name of this control for code behind ********** Code Behind Function **********  protected void  Your_Function_Name (object source, DataListCommandEventArgs e)         {             if (e.CommandName == "del")             { s...

itemcommand not working or firing in datalist or datagrid or gridview

Dear All I normally use this item command for enabling the editing through the Datalist control, right now i spend 4 hours because i didn't get why the itemcommand is not working when i click on the delete button under the Item template then i found the solution I have done the stupid mistake  if (!IsPostBack)             {                 // your loading function             } else             {  // My silly mistake i reload the datalist so remove this from your code it will work fine } Regards Rashid Imran Bilgrami http://www.bestvisualization.com

A critical error has occurred. Invalid postback or callback argument

Dear All Just now i got one error that arrives on clicking on the button under the item template A critical error has occurred. Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. Here is the solution Add the following line under web.config page <pages enableEventValidation="false"/> if you are using dnn then change the page line with the below line i change true to false     <pages validateRequest="false" enableViewStateMac="true" enableEventValidation=" ...

Set value in item template control (Label, hidden field or any other)

Dear All, It's a small thing but may be it helps you out, In the below example you did not want to go on code behind to set the value of hidden field just set the value directly through the ASCX databind option I consider you already bind the data in your data list, here is an example for binding the recID value in controller    <ItemTemplate> <asp:HiddenField ID="hfReserved" runat="server" Value='<%#Eval ("recID") %>' /> <asp:ImageButton ID="imgbtnSeat" runat="server" ImageUrl="Images/idlechair.png" CommandArgument='<%#Eval ("recID") %>' CommandName="Change" />                                     </ItemTemplate> Regards Rashid Imran Bilrgrami CEO Best visualization http://www.bestvisualization.com