If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Gridview In asp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-08, 01:40
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Thumbs down Gridview In asp

Hi i am new to asp and i have migrated to asp from asp.net
for some short term work.....
can i use gridview in asp?? if yes how? give me some links or example
if gridview is not available then how to add checkboxes to each row of html table????
my requirement is select some rows using checkbox and will submit the values

Thanks and regards
Ravi
Reply With Quote
  #2 (permalink)  
Old 12-15-08, 03:59
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
GridView is an ASP.NET control that cannot be used in Classic ASP.

As for your checkboxes; how are you currently generating your HTML table? The key is to make sure you giv each checkbox a unique value, but keep it within the same named collection.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-15-08, 04:03
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hi thanks for reply
But the table is not static...
It depends on the the number of rows fetched from the database.....
how to do it.Give me sample code...
can i use checkboxlist in ASP??

Thanks and regards
Ravi

Last edited by ravisakee; 12-15-08 at 04:10.
Reply With Quote
  #4 (permalink)  
Old 12-15-08, 04:42
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I understand that the table is not static, because in classic ASP you have to produce the result by looping...

Pseudo code
Code:
<table>
    <tr>
        <th>
            Column 1
        </th>
        <th>
            Column 2
        </th>
        <th>
            Checkbox
        </th>
    </tr>
<%
Do While Not rs.EOF
%>
    <tr>
        <td>
            <%=rs.col1%>
        </td>
        <td>
            <%=rs.col2%>
        </td>
        <td>
            <input type="checkbox" name="some_name" value="<%=rs.col1%>">
        </td>
    </tr>
<%
Loop
%>
</table>
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 12-15-08, 05:31
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
hi i tried that one
and my code like this..
<% @language = "VBScript" %>
<html>
<head>
</head>
<form name="getdetails">
<body>

<%

Dim ConnString
Dim cntArrive
ConnString = "Driver=SQL Server;server=sakee;uid=sa;pwd=admin;initial catalog=iguard"
set conn=server.createobject("adodb.connection")
set conn1=server.createobject("adodb.connection")
conn.Open ConnString
conn1.Open ConnString
Set rs1=conn1.execute("SELECT CONVERT(VARCHAR(8), GETDATE(), 112)+'-'+substring(com.container_no,1,11)+'-'+substring(cast(NEWID() as varchar(40)),1,3) as Container_ID,substring(com.container_no,1,11) as Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' as Entered_By,GETDATE() as Entered_Date,cotr.Origin,(select convert(varchar,com.Arrival_Date,101)) as Arrival_Date,(select convert(varchar,com.Arrival_Date,109)) as Arrival_Time from DehartGroup.dbo.Container_Master as com,DehartGroup.dbo.Container_Tracing as cotr where com.Container_No=cotr.Container_No and com.Seal_No=cotr.Seal_No")
Do while not rs.eof
cntArrive = cntArrive + 1
Do While Not rs1.EOF
%>
<tr>
<td><b>
<%=rs1.col1%>
</td>
<td>
<%=rs1.col2%>
</td>
<td>
<input type="checkbox" name="some_name" value=<%=rs1.col1%> >
</td>
</tr>
</table>

<%
Set rs=conn.execute(" INSERT into tblContainers (Container_ID,Container_No,Seal_No,Carrier,Entered _By,Entered_Date,Origin,Arrival_Date,Arrival_Time) SELECT CONVERT(VARCHAR(8), GETDATE(), 112) + '-' + SUBSTRING(com.container_no, 1, 11) + '-' + SUBSTRING(CAST(NEWID() AS VARCHAR(40)), 1, 3) AS Container_ID,SUBSTRING(com.container_no, 1, 11) AS Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' AS Entered_By,GETDATE() AS Entered_Date,cotr.Origin,(cast(CONVERT(datetime, com.Arrival_Date, 101) AS varchar(20))) aS Arrival_Date,CONVERT(VARCHAR(20), com.Arrival_Date,109) AS Arrival_Time FROM DehartGroup.dbo.Container_Master AS com INNER JOIN DehartGroup.dbo.Container_Tracing AS cotr ON (cotr.Container_No = com.Container_No) AND (cotr.Seal_No = com.Seal_No)")
conn.close
set conn =Nothing
set conn1=Nothing
set rs=nothing
set rs1=nothing

Loop

%>

</body>
</form>
</html>


but it throws error Expected 'Loop'

please help me
Reply With Quote
  #6 (permalink)  
Old 12-15-08, 05:41
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Ok, a couple of points....
  • You have no opening <table> tag.
  • You have a closing </table> tag inside the loop.
  • You are deallocating your rs1 variable inside the loop.
  • You have no rs1.MoveNext.
  • Your columns in the dataset are not called col1 and col2
    P.S. my code is syntactically incorrect on that bit too; it should be something more like <%=rs1("col1").Value%> - but you must realise I've written all this code in my head so it's untested and unlikely to work straight from the go.
  • Your rs command (the insert) is also inside the loop - it also looks like an expensive function that shouldn't be there!

Have you got your code to the point where it just shows all the records on the page? Once you've got that step down we can work on formatting using a table, and adding the checkbox.
__________________
George
Twitter | Blog

Last edited by gvee; 12-15-08 at 05:44.
Reply With Quote
  #7 (permalink)  
Old 12-15-08, 06:35
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hi..
Now i m able display data on the page and check box also coming on each row..
now i need to insert the data of the selected containers on click of button..
how to do it???
please do help


here is my code

<% @language = "VBScript" %>
<html>
<head>
</head>
<form name="getdetails">
<body>

<%

Dim ConnString
Dim cntArrive
ConnString = "Driver=SQL Server;server=sakee;uid=sa;pwd=admin;initial catalog=iguard"

set conn1=server.createobject("adodb.connection")

conn1.Open ConnString
Set rs1=conn1.execute("SELECT CONVERT(VARCHAR(8), GETDATE(), 112)+'-'+substring(com.container_no,1,11)+'-'+substring(cast(NEWID() as varchar(40)),1,3) as Container_ID,substring(com.container_no,1,11) as Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' as Entered_By,GETDATE() as Entered_Date,cotr.Origin,(select convert(varchar,com.Arrival_Date,101)) as Arrival_Date,(select convert(varchar,com.Arrival_Date,109)) as Arrival_Time from DehartGroup.dbo.Container_Master as com,DehartGroup.dbo.Container_Tracing as cotr where com.Container_No=cotr.Container_No and com.Seal_No=cotr.Seal_No")
Do While Not rs1.EOF
%>
<table>
<tr>
<td>
</td>
<td>
<input type="checkbox" name="some_name" value=<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Container_No").Value%>
</td>
</tr>
</table>

<%

rs1.movenext

Loop
%>
<%
set conn1=Nothing
set rs1=nothing

%>
<input type="submit" value="import Data">
</body>
</form>
</html>

Thanks and regards
Ravi
Reply With Quote
  #8 (permalink)  
Old 12-15-08, 08:46
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
You need to ad an action to your form that will fire on submission. I suggest you redirect to another ASP page for processing and then post back.
Ultimately you will still have to loop through the checkbox controls to pick up their values and perform your import action for each row that is selected.

P.S. </body></form></html> is in the wrong order. form should be within the body element.
__________________
George
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 12-15-08, 09:49
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
Hi i am redirecting to another page on btn click
but how to iterate through checkbox and how to pass the values to another page..
please do help sir

Thanks and regards
Ravi
Reply With Quote
  #10 (permalink)  
Old 12-15-08, 10:31
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
__________________
George
Twitter | Blog
Reply With Quote
  #11 (permalink)  
Old 12-16-08, 01:16
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
hi i tried using ur sample...
i am able to redirect to other page i am not getting the checkbox value..

this is my code.....


<% @language = "VBScript" %>
<html>
<head>
</head>
<form method="post" action="InsertData.asp" >
<body>

<%

Dim ConnString
Dim cntArrive
Dim temp
ConnString = "Driver=SQL Server;server=sakee;uid=sa;pwd=admin;initial catalog=iguard"

set conn1=server.createobject("adodb.connection")

conn1.Open ConnString
Set rs1=conn1.execute("SELECT CONVERT(VARCHAR(8), GETDATE(), 112)+'-'+substring(com.container_no,1,11)+'-'+substring(cast(NEWID() as varchar(40)),1,3) as Container_ID,substring(com.container_no,1,11) as Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' as Entered_By,GETDATE() as Entered_Date,cotr.Origin,(select convert(varchar,com.Arrival_Date,101)) as Arrival_Date,(select convert(varchar,com.Arrival_Date,109)) as Arrival_Time from DehartGroup.dbo.Container_Master as com,DehartGroup.dbo.Container_Tracing as cotr where com.Container_No=cotr.Container_No and com.Seal_No=cotr.Seal_No")
Do While Not rs1.EOF
%>
<table>
<tr>
<td>
<input type="checkbox" name="some_name" value=<%temp=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Seal_No").value%>
</td>

</tr>
</table>

<%

rs1.movenext

Loop
%>
<%
set conn1=Nothing
set rs1=nothing

%>
<input type="submit" value="import Data">
</form>
</body>
</html>

The other page code as follows


<% @language = "VBScript" %>
<html>
<head>
</head>
<form>
<body>
<%
temp=request.querystring("temp")

%>
<p>You have selected: <%Response.Write(temp)%></p>

</body>
</form>

i am not able to get the checkbox value based on selected checkbox values i am inerting values to database....

Thanks and regards

Ravi
Reply With Quote
  #12 (permalink)  
Old 12-16-08, 03:36
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
<html>
<head>
</head>
<form method="post" action="InsertData.asp" >
<body>
Come on mate, sort your tags out!
Forms are within the page body.

also, if you are using a POST event, you should be using Request.Form as it doesn't append to the query string.
__________________
George
Twitter | Blog
Reply With Quote
  #13 (permalink)  
Old 12-16-08, 04:24
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
hi thanks for ur help sir
I have sorted out the tags ,and using request.form but still its not getting the checkbox value


Thanks
Ravi
Reply With Quote
  #14 (permalink)  
Old 12-16-08, 04:40
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
<input type="checkbox" name="some_name" value=<%temp=rs1("Container_No").Value%>
Code:
temp=request.querystring("temp")
Highlighted needs to match.
__________________
George
Twitter | Blog
Reply With Quote
  #15 (permalink)  
Old 12-16-08, 06:40
ravisakee ravisakee is offline
Registered User
 
Join Date: Dec 2008
Posts: 36
hi i am getting check box value in my page ,but now the problem is
i want to insert only those values selcted by the user using checkbox ,
i cant put the condiotion in insert query.
How to do it???

<% @language = "VBScript" %>
<html>
<head>
</head>
<form method="post" action="InsertData.asp" >
<body>

<%

Dim ConnString
Dim cntArrive
Dim temp
ConnString = "Driver=SQL Server;server=sakee;uid=sa;pwd=admin;initial catalog=iguard"

set conn1=server.createobject("adodb.connection")

conn1.Open ConnString
Set rs1=conn1.execute("SELECT CONVERT(VARCHAR(8), GETDATE(), 112)+'-'+substring(com.container_no,1,11)+'-'+substring(cast(NEWID() as varchar(40)),1,3) as Container_ID,substring(com.container_no,1,11) as Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' as Entered_By,GETDATE() as Entered_Date,cotr.Origin,(select convert(varchar,com.Arrival_Date,101)) as Arrival_Date,(select convert(varchar,com.Arrival_Date,109)) as Arrival_Time from DehartGroup.dbo.Container_Master as com,DehartGroup.dbo.Container_Tracing as cotr where com.Container_No=cotr.Container_No and com.Seal_No=cotr.Seal_No")
Do While Not rs1.EOF
%>
<table>
<tr>
<td>
<input type="checkbox" name="some_name" value=<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Container_No").Value%>
</td>
<td>
<%=rs1("Seal_No").value%>
</td>

</tr>
</table>

<%

rs1.movenext

Loop
%>
<%
set conn1=Nothing
set rs1=nothing

%>
<input type="submit" value="import Data">
</form>
</body>
</html>

and another page in which i am using insert

<% @language = "VBScript" %>
<html>
<head>
</head>
<form action="get">
<body>
<%
Dim conno
conno=request.form("some_name")

Dim ConnString

ConnString = "Driver=SQL Server;server=sakee;uid=sa;pwd=admin;initial catalog=iguard"
set conn=server.createobject("adodb.connection")

conn.Open ConnString
Set rs=conn.execute("INSERT into tblContainers (Container_ID,Container_No,Seal_No,Carrier,Entered _By,Entered_Date,Origin,Arrival_Date,Arrival_Time) SELECT CONVERT(VARCHAR(8), GETDATE(), 112) + '-' + SUBSTRING(com.container_no, 1, 11) + '-' + SUBSTRING(CAST(NEWID() AS VARCHAR(40)), 1, 3) AS Container_ID,SUBSTRING(com.container_no, 1, 11) AS Container_No,com.Seal_No,com.Carrier,'IGuardTracki ng' AS Entered_By,GETDATE() AS Entered_Date,cotr.Origin,(cast(CONVERT(datetime, com.Arrival_Date, 101) AS varchar(20))) aS Arrival_Date,CONVERT(VARCHAR(20), com.Arrival_Date,109) AS Arrival_Time FROM DehartGroup.dbo.Container_Master AS com INNER JOIN DehartGroup.dbo.Container_Tracing AS cotr ON (cotr.Container_No = com.Container_No) AND (cotr.Seal_No = com.Seal_No) ")
conn.close
set conn =Nothing
%>
<p>Data Transferd successfully</p>
%>

</form>
</body>
</html>




Thanks and regardsa
Ravi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On