--------------------------------------------------------------------------------------------
1。GridView 常用功能:
获取模版列中 ID 与 TextBox 值:
TextBox NewName = (TextBox)GvGradeType.Rows[e.RowIndex].FindControl( " 控件ID " );
按钮实现GridView编辑,更新,删除,取消功能。
分别设置CommandName ,
编辑--CommandName="Edit",对应事件 RowEditing ,--(GridVier1.EditIndex = e.NewEditIndex;)
在编辑事件中查找 DropDownList 控件的例子,并指定 DataKeys 中选择的字段内容!~ (先绑定数据在查找字段)
NewName.SelectedValue = GvFamily.DataKeys[e.NewEditIndex][ 1 ].ToString();
更新--CommandName="Update",对应事件 RowUpdating
删除--CommandName="Delete",对应事件 RowDeleting
取消--CommandName="Cancel" ,对应事件 RowCancelingEdit,--(GridVier1.EditIndex = -1;)
替换--GridView 中的字体,对应事件 RowDataBound ,--对应的例子!~ 也可以写个对应的类替换!
{
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

----------------------------------------------------------------------------------------
3。DropDownList 控件改变索引 当前文本框获取 DropDownList 内的值(客户端无刷新)
</ 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文本框,使用说明(获取值到文本框,但是文本框不显示出来)
----------------------------------------------------------------------------------------
5。JS查找Html控件。(因为Lable生成的Html控件不是表单控件)


-----------------------------------------------------------------------------------------
6。判断页面是否传值-
{
Response.Write( " 没有传该值 " );
}
else
{
// 传值了可以引用
techid = Request.QueryString[ " techid " ].ToString();
}
------------------------------------------------------------------------------------------
7。DataList 中替换,查找模板列中的控件!
if (lbluser != null )
{
lbluser.Text = " 要替换的字符! " ;
}
--------------------------------------------------------------------------------------------
8。伪页面。picknews-1.aspx(伪) pick.aspx?id=1(真)
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 >