h1

Strankovani v Gridview pomoci ObjectDatasource

January 13, 2010

 

Pokud mate vlastni metodu vracejici jednu stranku z datoveho uloziste, pak jste urcite narazili na problem, ze GridView nema VirtualItemsCount property, aby jste mohli spocitat, kolik mate vubec v datovem zdroji stranek.

Property VirtualItemsCount je pouze v DataGridu.Nasledujici priklad tohle dokaze velice snadno obejit pomoci ObjectDataSource.

Funkční solution si můžete stáhnout zde

<asp:gridview ID="Gridview1" runat="server" AllowPaging="True" AutoGenerateColumns="True" DataSourceID="ObjectDataSource1"/>

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetMessages" TypeName="WebApplicationGWPaged.MessageProvider"SelectCountMethod="GetMessagesCount" EnablePaging=true MaximumRowsParameterName="pageSize" StartRowIndexParameterName="startIndex" />


Download

h1

Compare of two documents

December 10, 2009

 

 

Easy by tool CompareIt !

 

http://www.grigsoft.com/wincmp3.htm

I am using that for comparing of two Web.config files.

h1

Add value to registry (Examples)

November 3, 2009

 

to add dword value, create aa.reg file:

aa.reg

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:1

 

to add text value, create aa.reg file:

aa.reg

REGEDIT4

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"="text"

h1

Oracle basics

April 16, 2009

 

schema

 

Create foreign key

ALTER TABLE Schema.CONTRACT ADD
   CONSTRAINT FK_CONTRACT_PRODUCT
   FOREIGN KEY (PRODUCT_CODE)
   REFERENCES Schema.C_PRODUCT (PRODUCT_CODE)

Adding Grant to user

grant

select on C_PRODUCT to XXXACC

Must be called from XXX_DATA user, or other user which has privilagies to grant rules.

grant [select, update, delete,insert]  on C_PRODUCT to XXXACC

 

Create Sequence

create

sequence seq01 INCREMENT BY 1 MINVALUE 0 MAXVALUE 99999 START WITH 0;

 

Create Identity in Oracle 9i

First at all, create Sequence:

CREATE SEQUENCE seq01 INCREMENT BY 1 MINVALUE 0 MAXVALUE 99999 START WITH 0;

then you must create trigger, which gets new ID from sequence and than it fill Id attribute of new record before inserting.

CREATE

OR REPLACE TRIGGER [Schema].tg_bi_test
BEFORE
INSERT
ON [SCHEMA].SEQUENCEDTABLE

REFERENCING NEW AS New OLD AS
Old
FOR
EACH
ROW
DECLARE
tmpVar NUMBER
;

BEGIN
   tmpVar := 0;
   SELECT seq01.NEXTVAL INTO tmpVar FROM dual
;
   :NEW.id := tmpVar
;
   EXCEPTION
      WHEN OTHERS
THEN
      – Consider logging the error and then re-raise
      RAISE;
END
tg_bi_test;

Create stored procedure

CREATE

OR REPLACE PROCEDURE [SCHEMA].AddBank( Bank_Code CHAR,
 
Bank_Name CHAR,

  pCountry
CHAR

 
DEFAULT ‘XX’)

IS

BEGIN
INSERT INTO BANK (BankCode,BankName,Country)  VALUES(Bank_Code, Bank_Name,pCountry);
END
AddBank;


Call stored procedure

exec

ADDBANK(‘aaa’,‘bbb’);

(NHibernate call:)
var query =
session.CreateSQLQuery("call ADDBANK(:Bank_Code, :Bank_Name,:pCountry)");
query.SetString(
"Bank_Code", "0808");
query.SetString(
"Bank_Name", "Franklin’s bank");
query.SetString(
"pCountry", "XX");
var l = query.ExecuteUpdate();

 


h1

Loading image for Full PostBack

April 7, 2009

Loading image should be use, when user is waiting to performing “long time” server action.

When you will look to the internet, than you will probably find a lot of Ajax which will not work for full postback correctly (it is correctly working for update panels but not for whole page).

Solution

  • Use javascript, and set visibility style of animated gif to hidden
  • However you’ll press control which executes “long running” action, set visibility and timeout of animated gif
  • When processing finish, animated gif will be disabled again.

Links

h1

Telerik Reporting: Report with subreports and chart binded from ObjectdataSource

March 15, 2009

 

Following examaple  demonstrates easy report with subreports  (Master- Detail report). One of subreport contains chart. All repoerts are binded from one ObjectDataSource. And finally,  whole report is converted into the PDF file.  I dindn’t have a lot of time to investigate telerik reporting, but I am a bit disappointed, becouse 

  • I don’t know how to create charts without explicit binding of Chart-SeriesItems.
  • I have to handled ItemDataBinding or NeedDatasource events for binding subreports.
  • When I was creating Master-detail report, than I obtained  report with blank pages. There is solution.  I solved it in my sample too.

So, wipe it off and come up to example.  Following picture shows my test report.  Report is binded from class that contains few fielads and two lists.

reporting

And there is source code

Links

h1

Justice – stress

November 23, 2008

h1

Default values for FormView control in Insert mode

November 19, 2008

In many times we must assign default values to FormView in the insert mode. Problem is, that FW creates empty entity and this means empty FW.

Here is very short and powerful solution ;)

  • Add binding source to control which we want to set

    <asp:TextBox ID=”RateTextBox” runat=”server” Text=’<%# Bind(“Rate”) %> TabIndex=”24″ MaxLength=”5″ OnDataBinding=”InsertRateOnDataBinding />

  • Setting value to this control

    protected void InsertRateOnDataBinding(object sender, EventArgs e)
    {
      ((TextBox) sender).Text = RevertedOccupiedPercentage.ToString();
    }

h1

Regex designer tool

November 4, 2008

 

If you want to design and test your regular expressions, you should find any power  utility. There is one – Free Regular Expression Designer.

 

Links

h1

Percentage Regex

November 3, 2008

If you need percentage regex for positive percent numbers, you can use this:

  • ^0?[0-9]{0,2}(\,[0-9]{1,2})?$|^(100)(\,[0]{1,2})?$

Valid values: 100; 13,1; 001; 002,11; 100; 000; 0

Invalid values:  15.1; 15,x; 101; -2; -0

 

 

Follow

Get every new post delivered to your Inbox.