ms_dos

  博客园 :: 首页 ::  :: 订阅 订阅 :: 管理
  146 Posts :: 0 Stories :: 27 Comments :: 5 Trackbacks

2011年8月7日 #

protected void gvList_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
      if (e.Row.RowType == DataControlRowType.DataRow)
           e.Row.Cells[3].Text = e.Row.Cells[3].Text.Replace("\r\n", "<br>");

}

posted @ 2011-08-07 09:41 ms_dos 阅读(103) 评论(0) 编辑

2011年6月22日 #

已知dr为某DataRow,

1)如果从数据库读出来的值为null,在后台代码中可以这样判断:dr["fieldname"] is System.DBNull,而不是dr["fieldname"] == null。

 

2)给DataRow的某字段赋空值,使用:dr["fieldname"] = System.DBNull.Value;

posted @ 2011-06-22 14:03 ms_dos 阅读(135) 评论(0) 编辑

2011年4月29日 #

js:
<script language="javascript" type="text/javascript">
        function validateChklst(source, args) { 
//验证CheckBoxList必须选择且只能选择一个
            var obj = document.getElementById('<%=chklstConclusion.ClientID%>');
            var i, k 
= 0, isCheck = false;
            var tags 
= obj.all.tags('input');
            var n 
= tags.length; //返回obj对象里具有“input”标签对象的集合
            for (i = 0; i < n; i++) {
                
if (tags[i].checked) {
                    isCheck 
= true;
                    k
++;
                }
            }
            
if (isCheck && k == 1)
                args.IsValid 
= true;
            
else
                args.IsValid 
= false;
        }
</script>
 
前台aspx
<table border="0" cellspacing="0" cellpadding="0">
                
<tr>
                    
<td width="65">
                        评价结论:
                    
</td>
                    
<td>
                        
<asp:CheckBoxList ID="chklstConclusion" runat="server" RepeatDirection="Horizontal">
                            
<asp:ListItem>允许运行</asp:ListItem>
                            
<asp:ListItem>监督运行</asp:ListItem>
                            
<asp:ListItem>暂停运行</asp:ListItem>
                            
<asp:ListItem>停止运行</asp:ListItem>
                        
</asp:CheckBoxList>
                    
</td>
                    
<td>
                        
<asp:CustomValidator ID="cvConclusion" runat="server" ErrorMessage="*请选择评价结论(只能选择一个)!"
                            ClientValidationFunction
="validateChklst"></asp:CustomValidator>
                    
</td>
                
</tr>
</table>
 
 
posted @ 2011-04-29 16:36 ms_dos 阅读(95) 评论(0) 编辑

2011年2月14日 #

代码
protected void ddlDw_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddlDw 
= sender as DropDownList;
            GridViewRow gvRow 
= ddlDw.NamingContainer as GridViewRow;
            CheckBoxList chklXdzz 
= gvRow.FindControl("chklXdzz"as CheckBoxList;

            
string dwbh = gvUser.DataKeys[gvRow.RowIndex].Values[1].ToString();
            
string curDwbh = ddlDw.SelectedValue;
            
if (dwbh != curDwbh)
            {
                BindXdzz(chklXdzz, curDwbh);
            }
            
else
            {
                
string xdzzbh = gvUser.DataKeys[gvRow.RowIndex].Values[2].ToString();
                BindXdzz(chklXdzz, curDwbh, xdzzbh);
            }
        }

这里使用NamingContainer获取上一级数据容器,再通过该容器获取兄弟控件。

注意别忘记将ddlDw的AutoPostback属性设置为True。

posted @ 2011-02-14 15:52 ms_dos 阅读(129) 评论(0) 编辑

2011年1月5日 #

gvList.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
posted @ 2011-01-05 22:01 ms_dos 阅读(96) 评论(0) 编辑

2010年12月6日 #

摘要: <script type="text/javascript"> Array.prototype.indexOf = function (str) { for (var i = 0; i < this.length; i++) { if (str == this[i]) { return i; } } return -1; }</script>阅读全文
posted @ 2010-12-06 20:18 ms_dos 阅读(106) 评论(3) 编辑

2010年8月28日 #

摘要: AspxCallBack控件的CallBack事件1)不能弹出窗口;2)取AspxDropDownList控件客户端的值使用 ddl.ClientValue,而不是 ddl.Value;3)给控件的Text属性赋值无效,并不会改变页面上该控件呈现的值;如果需要改变,需在AspxCallBack控件客户端的CallbackComplete事件内修改控件客户端的Text值,如txtName.SetTe...阅读全文
posted @ 2010-08-28 10:23 ms_dos 阅读(112) 评论(0) 编辑

2010年8月27日 #

摘要: js中可以使用Math.round实现整数的四舍五入,如果需要实现精确到小数点多少位则需要编写自定义函数。方法一:function round(v,e) { var t=1; for(;e>0;t*=10,e--); for(;e<0;t/=10,e++); return Math.round(v*t)/t; } 参数里的: v表示要转换的值 e表示要保留的位数注意:如果使用用户控件,...阅读全文
posted @ 2010-08-27 22:55 ms_dos 阅读(117) 评论(0) 编辑

2010年8月5日 #

摘要: 方法一:<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("MeetingName") %>'NavigateUrl='<%# "~/Webpages/MeetingInfo.aspx?MeetingID="+Eval("MeetingID") %>' ></asp:HyperLink...阅读全文
posted @ 2010-08-05 15:33 ms_dos 阅读(49) 评论(0) 编辑

2010年7月11日 #

摘要: 代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-t...阅读全文
posted @ 2010-07-11 21:34 ms_dos 阅读(63) 评论(0) 编辑