知识 经验的积累

 

--------------------------------------------------------------------------------------------

1。GridView 常用功能:

获取模版列中 ID 与 TextBox 值:

int  categoryID  =  ( int )GvGradeType.DataKeys[e.RowIndex].Value;
TextBox NewName 
=  (TextBox)GvGradeType.Rows[e.RowIndex].FindControl( " 控件ID " );

 

按钮实现GridView编辑,更新,删除,取消功能。

分别设置CommandName ,

编辑--CommandName="Edit",对应事件 RowEditing ,--(GridVier1.EditIndex = e.NewEditIndex;)

在编辑事件中查找 DropDownList 控件的例子,并指定 DataKeys 中选择的字段内容!~ (先绑定数据在查找字段)

DropDownList NewName =  (DropDownList)GvFamily.Rows[e.NewEditIndex].FindControl( " 控件ID " );

NewName.SelectedValue 
=  GvFamily.DataKeys[e.NewEditIndex][ 1 ].ToString();

更新--CommandName="Update",对应事件 RowUpdating

删除--CommandName="Delete",对应事件 RowDeleting

取消--CommandName="Cancel" ,对应事件 RowCancelingEdit,--(GridVier1.EditIndex = -1;)

替换--GridView 中的字体,对应事件 RowDataBound ,--对应的例子!~ 也可以写个对应的类替换!

protected   void  GvCourseset_RowDataBound( object  sender, GridViewRowEventArgs e)
    {
        
if  (e.Row.RowType  ==  DataControlRowType.DataRow)
        {
            Label lblNewSing 
=  (Label)e.Row.FindControl( " lblSign " );
            
if  (lblNewSing  !=   null )
            {
                
if  (lblNewSing.Text  ==   " 1 " )
                {
                    lblNewSing.Text 
=   " " ;
                }
                
else
                {
                    lblNewSing.Text 
=   " " ;
                }
            }
        }
    }

 

----------------------------------------------------------------------------------------

2。弹出删除确认,在Onclice

OnClientClick="return confirm('您确认删除该记录吗?');"

----------------------------------------------------------------------------------------

3。DropDownList 控件改变索引 当前文本框获取 DropDownList 内的值(客户端无刷新)

< asp:DropDownList ID = " ddlGradeid "  runat = " server "  onchange = " setvalue(this) " >
            
</ asp:DropDownList >

function setvalue(slt)
    {
        document.form1.txtName.value 
=  slt.options[slt.selectedIndex].text;
    }

< input id = txtName type = text name = name size = 12  runat = " server "  maxlength = " 64 "   >

 

----------------------------------------------------------------------------------------

4。隐藏Html文本框,使用说明(获取值到文本框,但是文本框不显示出来)

< input id = " techid "  runat = " server "  name = " techid "  type = " hidden "   />

----------------------------------------------------------------------------------------

 5。JS查找Html控件。(因为Lable生成的Html控件不是表单控件)

var num  =  document.all( " lblNum " ).innerHTML;
< asp:Label ID = " lblNum "  runat = " server " ></ asp:Label >

-----------------------------------------------------------------------------------------

6。判断页面是否传值-

if  (Request[ " techid " ==   ""   ||  Request[ " techid " ==   null )
            {
                Response.Write(
" 没有传该值 " );
            }
            
else
            {
                
// 传值了可以引用
                techid  =  Request.QueryString[ " techid " ].ToString();
            }

------------------------------------------------------------------------------------------

7。DataList 中替换,查找模板列中的控件!

Literal lbluser  =  (Literal)e.Item.FindControl( " lbluser " );
        
if  (lbluser  !=   null )
        {
            lbluser.Text 
=   " 要替换的字符! " ;
        }

--------------------------------------------------------------------------------------------

8。伪页面。picknews-1.aspx(伪) pick.aspx?id=1(真)

< a href = " picknews-<%# Eval( " pub_id " ) %>.aspx " >
 Web.Config中配置
< RewriterConfig >
        
< Rules >
            
<!--  重写规则 -->
            
< RewriterRule >
                
<!-- 要实现的url格式 -->
                
< LookFor >~/ picknews - (d{ 1 , 6 }).aspx </ LookFor >
                
<!-- 真实的url地址.$ 1 .$ 2 ,$ 3 ...$N代表正则匹配的第N个表达式 -->
                
< SendTo >~/ pick.aspx ? id = $ 1 </ SendTo >
            
</ RewriterRule >
        
</ Rules >
    
</ RewriterConfig >

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值