datagrid

Ads
 

datagrid

please send datagrid in jsp lot fields including date

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

Ads









Related Tutorials/Questions & Answers:
datagrid
datagrid   please send datagrid in jsp lot fields including date
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
Advertisements
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
ModuleNotFoundError: No module named 'DataGrid'
ModuleNotFoundError: No module named 'DataGrid'  Hi, My Python... 'DataGrid' How to remove the ModuleNotFoundError: No module named 'DataGrid... to install padas library. You can install DataGrid python with following
ModuleNotFoundError: No module named 'DataGrid'
ModuleNotFoundError: No module named 'DataGrid'  Hi, My Python... 'DataGrid' How to remove the ModuleNotFoundError: No module named 'DataGrid... to install padas library. You can install DataGrid python with following
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
ModuleNotFoundError: No module named 'django-datagrid'
ModuleNotFoundError: No module named 'django-datagrid'  Hi, My... named 'django-datagrid' How to remove the ModuleNotFoundError: No module named 'django-datagrid' error? Thanks   Hi, In your python
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
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>
ModuleNotFoundError: No module named 'drf-dx-datagrid'
ModuleNotFoundError: No module named 'drf-dx-datagrid'  Hi, My... named 'drf-dx-datagrid' How to remove the ModuleNotFoundError: No module named 'drf-dx-datagrid' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'drf-dx-datagrid'
ModuleNotFoundError: No module named 'drf-dx-datagrid'  Hi, My... named 'drf-dx-datagrid' How to remove the ModuleNotFoundError: No module named 'drf-dx-datagrid' error? Thanks   Hi, In your python
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
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
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
core java
core java  hello sir....i have one table in which i have 3 columns First Name,Middle Name,Last Name...............but i have to show single name in datagrid view in jsp page using concat string tokenizer......for example- First
java
will be same now i have to show datagrid view as Name,Mobile,Address. For Example- f... to show datagrid as Name-raj kumar singh Mobile-89785675 Address-bangalore... how
Java
Java  hello sir.........i am doing one jsp project and i am having one table with columns first name middle name last name mobile number address i want to concat first,middle,last name and i have to show a datagrid view
richfaces jsf
is not displayed can anyone khw what is the reason display when i used rich:datagrid
Data Provider Controls in Flex
control DataGrid control Tree control ComboBox control Menu
VDividedBox layout container
; height="100%"> <mx:DataGrid height="70%"
Flex Map Application
source component used for inputting the data in your DataGrid or TileList
Jsp Grid
;.datagrid { border: 1px solid #C7C5B2; font-family: arial; font-size: 9pt; font-weight...:dataGrid items="&lt;%=promptlist%>" var="prompt" name="datagrid1" cellPadding="0" cellSpacing="0" styleClass="datagrid" > <columns></p> <
Introduction to RCFaces
,dataGrid </param-value> </init-param> <load-on-startup>1<
Sitemap JSP Tutorial Section
Chart in JSP | Draw Statistical chart in jsp | Paging Example in Datagrid JSP
problem with executing JSF file(Build failed)
; basicComponent,message,extraButton,tree,dataGrid <

Ads