CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

关于RadioButtonList的问题

楼主wanghuirui(wanghuirui)2005-06-03 20:59:35 在 .NET技术 / ASP.NET 提问

<asp:RadioButtonList   id="PayType"   runat="server"   Width="120px"><asp:ListItem   Value="1">   现金支付</asp:ListItem><asp:ListItem   Value="2">     E币支付</asp:ListItem><asp:ListItem   Value="3">   经验值支付</asp:ListItem>  
  </asp:RadioButtonList>  
   
  我在.cs文件中有这样的要求,当用户现金不足时,  
   
  “现金支付”这个选项呈灰色,不可选,怎么实现啊 问题点数:0、回复次数:6Top

1 楼boytomato(深爱一人叫颖的女孩!)回复于 2005-06-03 21:09:49 得分 0

<%@   Page   language="c#"   Codebehind="WebForm4.aspx.cs"   AutoEventWireup="false"   Inherits="WebService.WebForm4"   %>  
  <!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN"   >  
  <HTML>  
  <HEAD>  
  <title>WebForm4</title>  
  <meta   name="GENERATOR"   Content="Microsoft   Visual   Studio   .NET   7.1">  
  <meta   name="CODE_LANGUAGE"   Content="C#">  
  <meta   name="vs_defaultClientScript"   content="JavaScript">  
  <meta   name="vs_targetSchema"   content="http://schemas.microsoft.com/intellisense/ie5">  
  <script>  
                  function   onload()   {  
   
  var   radioButton   =   document.getElementsByTagName("input")  
  for   (var   i=0;i<radioButton.length;i++)   {  
  if   (radioButton[i].type   ==   "radio")   {  
                  if   (radioButton[i].value=="ALFKI")  
                  {  
    radioButton[i].disabled=true;  
    }  
   
  }  
  }  
   
  }  
   
  </script>  
  </HEAD>  
  <body   MS_POSITIONING="GridLayout"   onload="onload()">  
  <form   id="Form1"   method="post"   runat="server">  
  <FONT   face="宋体">  
  <asp:RadioButtonList   id="RadioButtonList1"   style="Z-INDEX:   101;   LEFT:   40px;   POSITION:   absolute;   TOP:   216px"  
  runat="server"   Height="56px"   Width="520px"></asp:RadioButtonList></FONT>  
  </form>  
  </body>  
  </HTML>  
   
   
  using   System;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Data;  
  using   System.Drawing;  
  using   System.Web;  
  using   System.Web.SessionState;  
  using   System.Web.UI;  
  using   System.Web.UI.WebControls;  
  using   System.Web.UI.HtmlControls;  
   
  namespace   WebService  
  {  
  ///   <summary>  
  ///   WebForm4   的摘要说明。  
  ///   </summary>  
  public   class   WebForm4   :   System.Web.UI.Page  
  {  
  protected   System.Web.UI.WebControls.RadioButtonList   RadioButtonList1;  
  protected   System.Data.OleDb.OleDbDataAdapter   oleDbDataAdapter1;  
  protected   System.Data.OleDb.OleDbCommand   oleDbSelectCommand1;  
  protected   System.Data.OleDb.OleDbConnection   oleDbConnection1;  
  protected   WebService.DataSet1   dataSet11;  
   
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
  //   在此处放置用户代码以初始化页面  
  this.oleDbDataAdapter1.Fill   (this.dataSet11   .Customers);  
    this.RadioButtonList1   .DataSource=this.dataSet11   .Customers   ;  
     
    this.RadioButtonList1.DataTextField="CustomerID";  
    this.RadioButtonList1.DataValueField="CustomerID";    
  this.RadioButtonList1   .DataBind();  
  }  
   
   
   
  #region   Web   窗体设计器生成的代码  
  override   protected   void   OnInit(EventArgs   e)  
  {  
  //  
  //   CODEGEN:   该调用是   ASP.NET   Web   窗体设计器所必需的。  
  //  
  InitializeComponent();  
  base.OnInit(e);  
  }  
   
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {          
  this.oleDbDataAdapter1   =   new   System.Data.OleDb.OleDbDataAdapter();  
  this.oleDbSelectCommand1   =   new   System.Data.OleDb.OleDbCommand();  
  this.oleDbConnection1   =   new   System.Data.OleDb.OleDbConnection();  
  this.dataSet11   =   new   WebService.DataSet1();  
  ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();  
  //    
  //   oleDbDataAdapter1  
  //    
  this.oleDbDataAdapter1.SelectCommand   =   this.oleDbSelectCommand1;  
  this.oleDbDataAdapter1.TableMappings.AddRange(new   System.Data.Common.DataTableMapping[]   {  
  new   System.Data.Common.DataTableMapping("Table",   "Customers",   new   System.Data.Common.DataColumnMapping[]   {  
    new   System.Data.Common.DataColumnMapping("CompanyName",   "CompanyName"),  
    new   System.Data.Common.DataColumnMapping("CustomerID",   "CustomerID")})});  
  //    
  //   oleDbSelectCommand1  
  //    
  this.oleDbSelectCommand1.CommandText   =   "SELECT   CompanyName,   CustomerID   FROM   Customers";  
  this.oleDbSelectCommand1.Connection   =   this.oleDbConnection1;  
  //    
  //   oleDbConnection1  
  //    
  this.oleDbConnection1.ConnectionString   =   @"User   ID=sa;Data   Source=GW;Tag   with   column   collation   when   possible=False;Initial   Catalog=Northwind;Use   Procedure   for   Prepare=1;Auto   Translate=True;Persist   Security   Info=False;Provider=""SQLOLEDB.1"";Workstation   ID=GW;Use   Encryption   for   Data=False;Packet   Size=4096";  
  //    
  //   dataSet11  
  //    
  this.dataSet11.DataSetName   =   "DataSet1";  
  this.dataSet11.Locale   =   new   System.Globalization.CultureInfo("zh-CN");  
  this.Load   +=   new   System.EventHandler(this.Page_Load);  
  ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();  
   
  }  
  #endregion  
  }  
  }  
   
   
   
   
  Top

2 楼boytomato(深爱一人叫颖的女孩!)回复于 2005-06-03 21:10:40 得分 0

function   onload()   {  
   
  var   radioButton   =   document.getElementsByTagName("input")  
  for   (var   i=0;i<radioButton.length;i++)   {  
  if   (radioButton[i].type   ==   "radio")   {  
                  if   (radioButton[i].value=="ALFKI")   //注意这    
                  {  
    radioButton[i].disabled=true;  
    }  
   
  }  
  }  
   
  Top

3 楼wanghuirui(wanghuirui)回复于 2005-06-03 23:34:59 得分 0

upTop

4 楼wanghuirui(wanghuirui)回复于 2005-07-03 20:40:19 得分 0

upTop

5 楼wt000000(店小2£)回复于 2005-07-03 20:50:22 得分 0

if   (radioButton[i].value=="ALFKI")    
   
  ALFKI是什么啊  
  Top

6 楼WZCNet(只有想不到,没有做不到)回复于 2005-07-03 20:51:52 得分 0

只能用JavaScript实现,实现代码楼上几位已回复,提醒注意的就是用JS设置的样式要页面第次回发时都要设置一下,因为JS的设置不会保存控件的状态Top

相关问题

  • datalist嵌套RadioButtonList
  • radiobuttonlist 与js
  • RadioButtonList问题
  • 有关datalist及radioButtonList
  • RadioButtonList控件问题??????
  • RadioButtonList的绑定问题
  • 怎样将Radiobuttonlist横着放
  • radiobuttonlist控件如何验证???
  • datagrid 增加RadioButtonList模板列?
  • RadioButtonList取值的问题

关键词

得分解答快速导航

  • 帖主:wanghuirui

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo