Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


pushpa
datagrid
5 Answer(s)      2 years ago
Posted in : JSP-Servlet


please send datagrid in jsp lot fields including date


Advertisement
View Answers

August 21, 2012 at 4:48 PM


Here is an example of jsp datagrid.In the given code,we have created the database table student(rollNo,name,address,dateOfBirth).

<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%!
public int nullIntconvert(String str){
int num=0;
if(str==null) {
str="0";
}
else if((str.trim()).equals("null")) {
str="0";
}
else if(str.equals("")) {
str="0";
}
try{
num=Integer.parseInt(str);
}
catch(Exception e) { }
return num;
}
%>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
ResultSet rs1 = null;
ResultSet rs2 = null;
PreparedStatement ps1=null;
PreparedStatement ps2=null;

int showRows=10;
int totalRecords=10;
int totalRows=nullIntconvert(request.getParameter("totalRows"));
int totalPages=nullIntconvert(request.getParameter("totalPages"));
int iPageNo=nullIntconvert(request.getParameter("iPageNo"));
int cPageNo=nullIntconvert(request.getParameter("cPageNo"));

int startResult=0;
int endResult=0;
if(iPageNo==0) {
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*showRows);
}
String query1="SELECT SQL_CALC_FOUND_ROWS * FROM student limit "+iPageNo+","+showRows+"";
ps1=conn.prepareStatement(query1);
rs1=ps1.executeQuery();

String query2="SELECT FOUND_ROWS() as cnt";
ps2=conn.prepareStatement(query2);
rs2=ps2.executeQuery();
if(rs2.next()) {
totalRows=rs2.getInt("cnt");
}
%>
<html>
<h3>Pagination of JSP page</h3>
<body>
<form>
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="showRows" value="<%=showRows%>">
<table width="100%" cellpadding="0" cellspacing="0" border="1" >
<tr>
<td>Roll No</td>
<td>Name</td>
<td>Address</td>
<td>Date Of Birth</td>
</tr>
<%
while(rs1.next()) {
    java.sql.Date dbSqlDate = rs1.getDate("dateOfBirth");
    java.util.Date date = new java.util.Date(dbSqlDate.getTime());
    SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
%>
<tr>
<td><%=rs1.getInt("rollNo")%></td>
<td><%=rs1.getString("name")%></td>
<td><%=rs1.getString("address")%></td>
<td><%=sdf.format(date)%></td>
</tr>
<%
}
%>
<%
try{
if(totalRows<(iPageNo+showRows)) {
endResult=totalRows;
}
else{
endResult=(iPageNo+showRows);
}
startResult=(iPageNo+1);
totalPages=((int)(Math.ceil((double)totalRows/showRows)));
}
catch(Exception e){
e.printStackTrace();
}
%>
<tr>
<td colspan="3">
<div>


August 21, 2012 at 4:49 PM


continue..

<%
    int i=0;
    int cPage=0;
    if(totalRows!=0) {
    cPage=((int)(Math.ceil((double)endResult/(totalRecords*showRows))));

    int prePageNo=(cPage*totalRecords)-((totalRecords-1)+totalRecords);
    if((cPage*totalRecords)-(totalRecords)>0){
    %>
    <a href="pagination.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
    <%
    }
    for(i=((cPage*totalRecords)-(totalRecords-1));i<=(cPage*totalRecords);i++){
    if(i==((iPageNo/showRows)+1)){%>
    <a href="pagination.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
    <%
    }
    else if(i<=totalPages){
    %>
    <a href="pagination.jsp?iPageNo=<%=i%>"><%=i%></a>
    <%
    }
    }
    if(totalPages>totalRecords && i<totalPages){
    %>
    <a href="pagination.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a>
    <%
    }
    }
    %>
    <b>Rows <%=startResult%> - <%=endResult%> Total Rows <%=totalRows%> </b>
    </div>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>


August 21, 2012 at 4:50 PM


Name above jsp code to pagination.jsp



August 21, 2012 at 4:51 PM




August 21, 2012 at 5:14 PM


thank you sir but i want to display grid view is contain scroll bars and if we want to select one row depending upon one column i want update the records details also

please send urgent i will submit the project in 5days



Related Tutorials/Questions & Answers:
datagrid
datagrid   please send datagrid in jsp lot fields including date
DataGrid in flex
DataGrid in flex  Hi..... Please tell me about DataGrid extends which class? please give me the syntax......... Thanks
Advertisements
DataGrid in flex
DataGrid in flex  Hi.... Please tell me What is the data type of the dataprovider property in DataGrid? please give an small example for that.... Thanks
DataGrid in flex
DataGrid in flex  Hi....... I want to know about How do you access methods in DataGrid from external itemRenderers? please give an example so i can clearly understand.... Thanks
DataGrid in flex
DataGrid in flex  Hi.... What kind of data grids you can create through Flex applications? please tell me about the datagrid so i can implement it in my application .... Thanks
Datagrid not working
Datagrid not working  The code here is working fine, apart from... the datagrid tag gives an error saying that the items attribute does not accept ant... This works fine for datagrid but then the javascript for drop down menu stops
ArrayCollection in DataGrid
ArrayCollection in DataGrid  Hi.... I want to know about What are the advantages of using arraycollection as a dataprovider instead of array in DataGrid? please give the ans ASAP....... Thanks
DataGrid in flex
DataGrid in flex  Hi........ Please provide the solution of that problem When I add or modify an item in my dataProvider, why doesn't it show up in my DataGrid? Thanks in advance  Ans: When you work
DataGrid in flex
DataGrid in flex  Hi.... please provide the solution of that problem When I have only a single record, why doesn't it appear in my DataGrid? please give an example Thanks  Ans: This is a caused in flex
jsp-datagrid
jsp-datagrid  hello sir.....i have 20 records in my database and i am showing those data in datagrid view but now i want to show 10 data in one page... option in my datagrid view with 1,2 pages....plz help me...awaiting for your
jsp-datagrid
jsp-datagrid  hello sir.....i have 20 records in my database and i am showing those data in datagrid view but now i want to show 10 data in one page... option in my datagrid view with 1,2 pages....plz help me...awaiting for your
editable datagrid
editable datagrid  How to create a editable datagrid in jsp,struts1.3,glassfish v2.x application server and database oracle using netbeans6.8 ide?   Hi Friend, Please visit the following link: http://www.roseindia.net
DataGrid ItemRenderer
DataGrid ItemRenderer  Hi... I have a datagrid which contains a Spark dropdownlist that needs to obtain dynamic data. The datagrid uses a separate..." backgroundColor="#000000"> <mx:DataGrid id="myDG" dataProvider="{myDP
jsp-datagrid
jsp-datagrid  hello sir...i have one view page in which edit and delete option are there in a datagrid view and i want to show data in page wise(pagination)...with previous and next links....i am also attaching my code for your
jsp-datagrid
jsp-datagrid  hello sir...i have one view page in which edit and delete option are there in a datagrid view and i want to show data in page wise(pagination)...with previous and next links....i am also attaching my code for your
jsp-datagrid
jsp-datagrid  hello sir...i have one view page in which edit and delete option are there in a datagrid view and i want to show data in page wise(pagination)...with previous and next links....i am also attaching my code for your
datagrid including combobox
datagrid including combobox  please send datagrid in jsp using mysql database based on id in the datagrid select each record and also update record with available to old values updation is done in form wise. using combo box
Datagrid in JSP - JSP-Servlet
Datagrid in JSP  I Want to display some record in datagrid of JSP page. I am using Apache tomcat server. please help me.  Hi Friend, Please visit the following code: http://www.roseindia.net/jsp/data-grid.shtml
datagrid in JSP - JSP-Servlet
datagrid in JSP  sir i want code t create a datagrid view in JSP. I am using oracle 10g. please help me.  Hi Friend, Please visit the following code: http://www.roseindia.net/jsp/data-grid.shtml Hope
datagrid search - Hibernate
datagrid search  Hi friend, i have displayed a datagrid using jsp but i need a search option in that which is used to display and sort it in a alphabetical order.... pls help me... Thanks in advance...   
DataGrid without DataBase
DataGrid without DataBase  I want display list of data without using database. Ex- Employee have some elements like- name, sex, place, designation. I have to display the content of these elements but without having
ComboBox ItemRenderer in DataGrid
ComboBox ItemRenderer in DataGrid  Hi..... How can I create custom combo box itemtenderer in the flex datagrid? please give me an example...; <mx:DataGrid id="myDG" dataProvider="{myDP
How to get data datagrid ?
How to get data datagrid ?  How to get data datagrid in jsp from arrayList in java? Code in java CategoryDao dao = new CategoryDao(); ArrayList<Categories> lstCategory = new ArrayList<Categories>
DataGrid Control in Flex4
DataGrid control in Flex4: The DataGrid control is a MX component. There is no spark component. DataGrid Control is like a Table in html. The DataGrid.... It supports for paging. You can use ArrayList or AvtionScript for creating a DataGrid
DataGrid in Flex
Adobe Flex DataGrid: In Flex, DataGrid is a kind of list which can display... column. Adobe Flex DataGrid provides many features like columns can be resized...;mx:ArrayCollection> and <mx:Object> tags. Adobe Flex Datagrid
How can i write a datagrid coding - Java Beginners
How can i write a datagrid coding  Hi, I want make a datagrid..plz send me datagrid coding using mysql database and jsp..plz tell me brief description about grid how can i connect datagrid with database. Thanks
how to make a matrix like datagrid in ide in java pls help
how to make a matrix like datagrid in ide in java pls help  how to make a datagrid mainly matrix in ajava standalone app
Flex DataGrid control
DataGrid in Flex:- A DataGrid is a control in flex which is display data... and display via custom renderers. The main features of the DataGrid is that, you can... a DataGrid and what is the procedure to provide data by array collection
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.
I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid.  I want to Populate ComBobox value from database that combox is Itemrenderer of DataGrid
How to add a DropDown List in Flex DataGrid
a DropDownList in a DataGrid table. After the user selects one of the items from... a dropDownList in dataGrid. Pls can u tell me how the selected item in my dropdownlist can be recognize and update the value of the cell in the dataGrid and save
How to add a DropDown List in Flex DataGrid
a DropDownList in a DataGrid table. After the user selects one of the items from... a dropDownList in dataGrid. Pls can u tell me how the selected item in my dropdownlist can be recognize and update the value of the cell in the dataGrid and save
JSP Paging Example in Datagrid - JSP-Servlet
JSP Paging Example in Datagrid  Hi, I have tested JSP Paging Example in Datagrid which is available at the following url which i am able to run it successfully. http://www.roseindia.net/jsp/paging.shtml When i try
JSP Paging Example in Datagrid - JSP-Servlet
========================================= Paging Example Using Datagrid th a:link...-color: cyan; color: #000000;font-weight: bold } .datagrid { border
How to create a OLAP DataGrid in Flex4
How to create a OLAP DataGrid in Flex4: The following figure shows the procedure for create a OLAPDataGrid control. There are the following procedure for create a OLAPDataGrid: 1.Start with a flat data in a local collection
JSP Paging Example in Datagrid
JSP Paging Example in Datagrid       In this section, we have developed a web application to create paging in JSP. Two files are used "paging.jsp" and "
AdvancedDataGrid Control in Flex4
AdvancedDataGrid control in Flex4: The AdvancedDataGrid control is same as a DataGrid control. It has a functionality of the standard DataGrid control. It provides the good control of data display and data formatting. You can provide
About OLAP Cube in OLAP DataGrid in Flex4
About OLAP Cube in OLAP DataGrid in Flex4: OLAP cube have many dimensions. Dimensions of an OLAP cube represent the field of the flat data. for example: value:Object = { product:"monitor" month :"Jan" price
About OLAP Schemas in OLAP DataGrid in Flex4
About OLAP Schemas in OLAP DataGrid in Flex4: OLAP Schema is used for to convert a flat data in to an OLAP cube. You will create OLAP schema which is used for defines the dimensions of the cube. The fields of the flat data that supply
SweetDEV RIA
SweetDEV RIA       SweetDEV RIA contains widgets such as with Datagrid, Combo multiselect, Virtual window, Calendar, Click to open, Expand/Collapse, Excel export, client /server
Copying and Moving data using drag and drop
from list to dataGrid using different data formats in this example. When you...(); event.currentTarget.hideDropFeedback(event); var dropTarget:DataGrid = DataGrid...:DataGrid id="studentData" allowMultipleSelection="
Asp.net - Development process
Asp.net  hi! how to display image in datagrid by using backend
how can i create a data grid - Java Beginners
plz help me i want make a datagrid but i have no idea about this how can i create datagrid. and how can i connect to the database plz help me give brief description abut datagrid using jsp and mysql. this information send
datagid with paging using jsp - Ajax
datagid with paging using jsp  datagrid with paging using ajax and jsp  Hi friend, For read more information : http://www.roseindia.net/jsp/data-grid.shtml Thanks
Flex difference
2. flex ajax bridge 3. Two newly added component Advanced datagrid and OLAP dataGrid 4. Flex component kit for flash CS3 5. cross-domain facility 6. Added
DOJO - Ajax
DOJO  please send editable datagrid code with paging for update,delete and insert using jsp with dojo.  Hi friend, Read for more information. http://www.roseindia.net/jsp/implement-javascript-with-jsp.shtml
java
,address column will be same now i have to show datagrid view as Name,Mobile,Address...=bangalore i have to show datagrid as Name-raj kumar singh Mobile-89785675 Address
Reply Me - Java Beginners
be stored in datagrid with joining in main page For page details In main... windows In the popup window have a one datagrid(for sales_line) and one... the company master table as well as vend_id for sales_line (which have datagrid
Advertisements
 

 

 

DMCA.com