==================VFPAGE=============
<apex:page sidebar="false" controller="task3b">
<style Type="text/css">
.ashok{
background-color:blue;
}
</style>
<apex:form id="f">
<apex:pageBlock title="Edit/Delete" mode="Edit" tabStyle="Book__c">
<apex:pageblockTable var="bk" value="{!bkList}">
<apex:column headerValue="Action">
<apex:outputLink title="" value="/{!bk.id}/e?retURL=/apex/{!$CurrentPage.Name}">Edit</apex:outputLink>
<a href="javascript:if (window.confirm('Are you sure?')) DeleteRecord('{!bk.Id}');" style="font-weight:bold">Del</a>
</apex:column>
<apex:column value="{!bk.name}"/>
<apex:column value="{!bk.Price__c}"/>
</apex:pageblockTable>
<apex:actionFunction name="DeleteRecord" action="{!Del}" reRender="f" >
<apex:param value="" name="Rec" assignTo="{!bl}"/>
</apex:actionfunction>
</apex:pageBlock>
</apex:form>
</apex:page>
==========CONTROLLER===============
public with sharing class task3b {
public void Del() {
if(bl==null){
return ;
}
book__c bl1=null;
for(book__c bks:bklist){
if(bks.id==bl){
bl1=bks;
}
}
if(bl1!=null){
delete bl1;
}
AshokMehtod();
}
public void AshokMehtod(){
bkList=[select id,name,author__c,price__c from book__c];
}
public task3b(){
AshokMehtod();
}
public string bl{set;get;}
public List<book__c> bkList {get; set;}
}
<apex:page sidebar="false" controller="task3b">
<style Type="text/css">
.ashok{
background-color:blue;
}
</style>
<apex:form id="f">
<apex:pageBlock title="Edit/Delete" mode="Edit" tabStyle="Book__c">
<apex:pageblockTable var="bk" value="{!bkList}">
<apex:column headerValue="Action">
<apex:outputLink title="" value="/{!bk.id}/e?retURL=/apex/{!$CurrentPage.Name}">Edit</apex:outputLink>
<a href="javascript:if (window.confirm('Are you sure?')) DeleteRecord('{!bk.Id}');" style="font-weight:bold">Del</a>
</apex:column>
<apex:column value="{!bk.name}"/>
<apex:column value="{!bk.Price__c}"/>
</apex:pageblockTable>
<apex:actionFunction name="DeleteRecord" action="{!Del}" reRender="f" >
<apex:param value="" name="Rec" assignTo="{!bl}"/>
</apex:actionfunction>
</apex:pageBlock>
</apex:form>
</apex:page>
==========CONTROLLER===============
public with sharing class task3b {
public void Del() {
if(bl==null){
return ;
}
book__c bl1=null;
for(book__c bks:bklist){
if(bks.id==bl){
bl1=bks;
}
}
if(bl1!=null){
delete bl1;
}
AshokMehtod();
}
public void AshokMehtod(){
bkList=[select id,name,author__c,price__c from book__c];
}
public task3b(){
AshokMehtod();
}
public string bl{set;get;}
public List<book__c> bkList {get; set;}
}
No comments:
Post a Comment