Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am trying to create a checkbox group using old styled adodb recordset because microsoft checkboxlist object doesn't let you apply

 

align='right' valign='top'

 

formatting to the column the checkboxes are in.

 

I created a recordset as follows

 

Conn = Server.CreateObject("ADODB.Connection")

Conn.Open(....)

 

SQL = "select rtrim(onet3_desc) as desc_trim, onet3_cd from onet3 where onet3_cd like '1110%'"

 

rs = Server.CreateObject("ADODB.Recordset")

rs.Open( SQL, Conn, 3)

 

and when I try to get the value of a field as

 

rs.Fields("onet3_cd")

 

it comes back with an error saying

 

"Invalid number of parameters"

 

What is the proper way to get recordset values in .net?

 

If you know any oher way to dynamically create checkboxes on the html page please let me know.

 

Thank you,

 

Burak

Posted (edited)

Hello Robby,

 

rtrim is an oracle function. I was able to get it to work.

 

I was able to use old style adodb recordset to dynamically create checkboxes in an aspx page.

 

But for some reason, the page_onload sub is not getting called when I submit the page to itself.

 

My code is below. Any ideas will be appreciated.

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test4.aspx.vb" aspcompat="true" Inherits="vets.test4"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test4</title>
<script language=vb runat=server>

 Dim ctrIndex as integer

 sub page_onload()
  ctrIndex = 1	    
  if request.form("ctrIndex") = ""  then
 ctrIndex = 1
  else
 ctrIndex = request.form("ctrIndex")
  end if

  If   request.form("desc1")="on" then
    response.write("First description is on" )
 end if		

 Response.write("ctrIndex =" & ctrIndex )

 end sub
	
</script>
	
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" action="test4.aspx">
<%
   Dim conn
   Dim rs
   Dim SQL
   			    
   Conn = Server.CreateObject("ADODB.Connection")
   Conn.Open(....)

   SQL = "select rtrim(onet3_desc) as desc_trim, onet3_cd from onet3 " & _
  "where onet3_cd like '1110%'" 
		
   rs = Server.CreateObject("ADODB.Recordset")
   rs.Open( SQL, Conn, 3)
%>
		
<table>
 <%  While Not rs.EOF 	%>
 <tr>
  <td align=right valign=top>
 <INPUT type='checkbox' name='desc<%=ctrIndex>'      value='<%=rs.Fields("onet3_cd").Value.ToString()%>'>
  </td>
  <td>
  <%=rs.Fields("desc_trim").Value.ToString()%>
  </td>
 </tr>
 <%     
  ctrIndex = ctrIndex + 1
  rs.MoveNext
   End While 
 %>	
 </table>
  <%
   rs.Close
   Conn.Close
  %>
  <input type='submit' runat='server' id='btnSubmit' value='Click'>	
 </form>
 </body>
</HTML>

Edited by Robby

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...