首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏张善友的专栏

    Page.FindControl方法找不到指定控件的原因

    在ASP.NET 2.0中,引入了MasterPage的机制,在当前页使用MasterPage的情况下,放在 ContentPlaceholder1这样的内容页的控件无法用Page.FindControl MSDN对FindControl的解释:在当前的命名容器中搜索带指定 id 参数的服务器控件 这里有一篇文章阐述阐述FindControl方法和INamingContainers接口:http://www.odetocode.com 譬如当有GridView存在的话,GridView其实也是一个naming container,要找GridView中的一个ControlID,就不能用Page.FindControl,而得用[GridView 对象].FindControl方法。 很多时候,因为是动态控件,明知道是在同一个naming container中,但不知道该naming container是什么对象,一个控件要找到另一个控件,可以用this.Parent.FindControl

    1.7K70发布于 2018-01-19
  • 来自专栏全栈程序员必看

    GridView编辑删除操作

    (“LB_edit”)).Visible = false; ((LinkButton)GV_Main.Rows[rowIndex].FindControl(“LB_upd”)). [rowIndex].FindControl(“lbl_ctrq”)).Visible = false; ((TextBox)GV_Main.Rows[rowIndex].FindControl = false; ((LinkButton)GV_Main.Rows[rowIndex].FindControl(“LB_cancel”)).Visible = false; ((Label)GV_Main.Rows[rowIndex].FindControl(“lbl_chanpin”)).Visible = true; (( [rowIndex].FindControl(“lbl_ctrq”)).Visible = true; ((TextBox)GV_Main.Rows[rowIndex].FindControl

    2.3K20编辑于 2022-07-14
  • 来自专栏米扑专栏

    VS2008(C#)子页嵌套母版页的控件访问方法(三)

    ("ContentPlaceHolder2");         Label m3Label = (Label)cpMaster2.FindControl("Master3_Label");         ("ContentPlaceHolder2");         Label m3Label = (Label)cpMaster2.FindControl("Master3_Label");         ("ContentPlaceHolder1");         Label m2Label = (Label)cpMaster1.FindControl("Master2_Label");         ("ContentPlaceHolder1");         Label m2Label = (Label)cpMaster1.FindControl("Master2_Label");         Button5_Click(object sender, EventArgs e)     {         Label mLabel = (Label)Master.Master.Master.FindControl

    1.6K30发布于 2019-02-19
  • 来自专栏全栈程序员必看

    Repeater使用方法—基础数据绑定+多级嵌套「建议收藏」

    ("lblSex"); LinkButton lbupdate = (LinkButton)e.Item.FindControl("update"); LinkButton lbdelete = (LinkButton)e.Item.FindControl("delete"); if (lblsex! == ListItemType.AlternatingItem) { HiddenField hf = (HiddenField)e.Item.FindControl ("hfid"); Repeater rpchild = (Repeater)e.Item.FindControl("childRepeater"); ("hfidchild"); Repeater rpgrantchild = (Repeater)e.Item.FindControl("grantchildRepeater

    1.7K20编辑于 2022-09-06
  • 来自专栏Java架构师必看

    保持dropdownlist选中值

    e.Row.Attributes["style"] = "Cursor:hand";         //问题分类下拉框绑定选中值         if (((DropDownList)e.Row.FindControl = null)         {             DropDownList ddlProVar = (DropDownList)e.Row.FindControl("ddlProVar") ;             SetSelectedItem(ddlProVar, ((HiddenField)e.Row.FindControl("hdProVarState")).Value);        

    88510发布于 2020-07-21
  • 来自专栏全栈程序员必看

    listview嵌套GridView_react grid layout

    GridView1.DataBind(); sqlcon.Close(); } ========================================= 我已经通过FindControl if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[ 1 ].FindControl ( “ GridView2 “ ); } } 可是在FindControl(“GridView2”)后只有一个DataBind()方法,并没有DataSource ——————————————————– GridView GRTemp=(GridView)e.Row.Cells[1].FindControl(“GridView2”); GRTemp.DataSource DataRowView rowv = (DataRowView)e.Row.DataItem; Label lblCareer = (Label)e.Row.FindControl

    68410编辑于 2022-11-10
  • 来自专栏学习计划

    GridView数据库分页+自定义分页导航(二):自定义分页导航。首页、上一页、下一页、尾页和跳转

    case "-3": int p = Convert.ToInt32(((DropDownList)codeTable.BottomPagerRow.FindControl ((Label)codeTable.BottomPagerRow.FindControl("pageNumber")).Text = PageIndex + ""; ((Label )codeTable.BottomPagerRow.FindControl("totalNumber")).Text = PageCount + ""; ? for (int i = 1; i <= PageCount; i++) ((DropDownList)codeTable.BottomPagerRow.FindControl int p = Convert.ToInt32(((DropDownList)codeTable.BottomPagerRow.FindControl("pageList")).SelectedValue

    2.5K10发布于 2021-01-29
  • 来自专栏全栈程序员必看

    两个Repeater嵌套使用「建议收藏」

    e.Item.ItemType == ListItemType.AlternatingItem)) { //string classname = ((Button)e.Item.FindControl .Text; DataRowView drv = (DataRowView)e.Item.DataItem; Repeater rptProductList = (Repeater)e.Item.FindControl e.Item.ItemType == ListItemType.AlternatingItem)) { //string classname = ((Button)e.Item.FindControl (“gDel”)).Text; DataRowView drv = (DataRowView)e.Item.DataItem; Image image = (Image)e.Item.FindControl goodsImg”); image.ImageUrl = drv[“cContentImg”].ToString(); Label label = (Label)e.Item.FindControl

    59420编辑于 2022-09-14
  • 来自专栏米扑专栏

    VS2008(C#)子页嵌套母版页的控件访问方法(二)

    ContentPlaceHolder,来访问其中的控件(此时已为第二层)         ContentPlaceHolder cpMaster1 = (ContentPlaceHolder)Master.Master.FindControl ("ContentPlaceHolder1");         Label m2Label = (Label)cpMaster1.FindControl("Master2_Label");         ("ContentPlaceHolder1");         Label m2Label = (Label)cpMaster1.FindControl("Master2_Label");         protected void Button3_Click(object sender, EventArgs e)     {         Label mLabel = (Label)Master.Master.FindControl protected void Button4_Click(object sender, EventArgs e)     {         Label mLabel = (Label)Master.Master.FindControl

    1.8K10发布于 2019-02-19
  • 来自专栏Java架构师必看

    GridView控件修改、删除示例(修改含有DropDownList控件)

    GridView1_RowDataBound( object  sender, GridViewRowEventArgs e)     { if  (((DropDownList)e.Row.FindControl = null )         {                     DropDownList ddlxueli  =  (DropDownList)e.Row.FindControl // //   选中 DropDownList             ddlxueli.SelectedValue  =  ((HiddenField)e.Row.FindControl ( " TBCard " )).Text; string  xueli  =  ((DropDownList)GridView1.Rows[e.RowIndex].FindControl ( " DDLXueli " )).SelectedValue; string  price  =  ((TextBox)GridView1.Rows[e.RowIndex].FindControl

    93420发布于 2021-03-22
  • 来自专栏Java架构师必看

    在GridView内访问特定控件

    GridViewRow row in GridView1.Rows) { // 从GridView中的TextBox控件得到文本 string textBoxText = ((TextBox)row.FindControl Response.Write(textBoxText); // 从GridView中的DropDownLis控件得到选定值 string dropDownListText = ((DropDownList)row.FindControl SelectedItem.Value; Response.Write(dropDownListText); // 从GridView中的ListBox控件选择值 ListBox myListBox = (ListBox)row.FindControl Response.Write(selectedItem.Value); } } } 以上代码中我们做过的都是使用GridViewRow对象来循环访问 GridView控件中的所有行,下一步我们将使用FindControl

    3.9K40发布于 2021-03-22
  • 来自专栏c#开发者

    Add a FileUpload control to your GridView [转]

    object sender, GridViewUpdateEventArgs e) {     FileUpload fileUpload = GridView1.Rows[e.RowIndex].FindControl When you have the instance of the GirdView’s row, you can use the FindControl method to locate the FileUpload FindControl("FileUpload1") as FileUpload;       fileUpload.SaveAs(System.IO.Path.Combine("C:""", fileUpload.FileName _Inserting(object sender, ObjectDataSourceMethodEventArgs e) { FileUpload upload = DetailsView1.FindControl

    1.6K60发布于 2018-04-12
  • 来自专栏偏前端工程师的驿站

    GridView实战一:自定义分页、排序、修改、插入、删除

    == -1) 25 { 26 //设置性别 27 RadioButtonList rbl = e.Row.FindControl int id = Convert.ToInt32(this.gv.DataKeys[e.RowIndex].Value); 172 string name = (gvr.Cells[0].FindControl ).SelectedValue; 174 string country = (gvr.Cells[2].FindControl("ddlCountry") as DropDownList ("tbxName") as TextBox).Text; 200 string sex = (tr.Cells[0].FindControl("rblSex") as RadioButtonList ).SelectedValue; 201 string country = (tr.Cells[0].FindControl("ddlCountry") as DropDownList)

    3.5K100发布于 2018-01-18
  • 来自专栏全栈程序员必看

    repeater控件用法_propertygrid控件

    = ((DataRowView)e.Item.DataItem).Row[“au_id”].ToString(); Repeater repeaterSub = (Repeater)e.Item.FindControl string au_id = ((DataRowView)e.Item.DataItem).Row[“id”].ToString(); CheckBox chk = (CheckBox)e.Item.FindControl meun_role r on ur.roleid=r.id “ + “where u.id=” + au_id; Repeater repeaterSub = (Repeater)e.Item.FindControl i = 0; i < this.group_manage.Items.Count; i++) { CheckBox chk = (CheckBox)group_manage.Items[i].FindControl

    2.2K20编辑于 2022-11-04
  • 来自专栏全栈程序员必看

    Repeater嵌套DataList

    ListItemType.AlternatingItem) { DataList childs = (DataList)e.Item.FindControl strFirstNo = rows["bigid"].ToString(); Label l = (Label)e.Item.FindControl parent.Items.Count; i++) { DataList myDataList = (DataList)parent.Items[i].FindControl myDataList.Items.Count; j++) { CheckBox myCheckBox = (CheckBox)myDataList.Items[j].FindControl

    59930编辑于 2022-09-14
  • 来自专栏更流畅、简洁的软件开发方式

    给自定义控件(Web Control)添加事件的几种方法。前两种方法可以不实现IPostBackEventHandler

    btn_Click); }  void btn_Click(object sender, EventArgs e)         {             Label lbl = (Label)this.FindControl  EventTest1_myClick(object sender, EventArgs e)         {             Label lbl = (Label)EventTest1.FindControl void btn_Click(object sender, EventArgs e)         {             Label lbl = (Label)this.FindControl(         public void RaisePostBackEvent(string Index)         {             Label lbl = (Label)this.FindControl 由现有的控件的事件触发          void btn_Click(object sender, EventArgs e)         {             Label lbl = (Label)this.FindControl

    1.5K70发布于 2018-02-26
  • 来自专栏Java架构师必看

    ASP.NET2.0中用Gridview控件操作数据

    将新增的记录更新到数据库中去 void Button1_Click(object sender, EventArgs e) { TextBox customerID = Gridview1.FooterRow.FindControl ("CustomerIDTextBox") as TextBox; TextBox companyName = Gridview1.FooterRow.FindControl("CompanyNameTextBox ") as TextBox; DropDownList ContactTitle = Gridview1.FooterRow.FindControl("ContactTitleDropDownList" ("TextBox2")).Text; SqlDataSource1.UpdateParameters[1].DefaultValue = ((TextBox)row.Cells[1].FindControl ("TextBox2")).Text.Replace("’", "’’"); string value2 = ((TextBox)row.Cells[1].FindControl("TextBox3")

    2.1K10发布于 2021-03-22
  • 来自专栏偏前端工程师的驿站

    GridView实战二:使用ObjectDataSource数据源控件

    -1) 18 { 19 //设置性别 20 RadioButtonList rbl = e.Row.FindControl [1].Selected = true; 39 //国籍 40 DropDownList ddlCountry = e.Row.FindControl li); 50 } 51 //兴趣 52 CheckBoxList cbl = e.Row.FindControl ") as RadioButtonList).SelectedValue; 92 string Country = (this.gv.Rows[this.gv.EditIndex].FindControl new System.Text.StringBuilder(); 94 foreach (ListItem li in (this.gv.Rows[this.gv.EditIndex].FindControl

    2K100发布于 2018-01-18
  • 来自专栏全栈程序员必看

    C# Repeater嵌套循环[通俗易懂]

    )e.Item.DataItem).Row["ID"].ToString();//获得对应ID Repeater repeater= (Repeater)e.Item.FindControl ("users_list");//找到要绑定数据的Repeater //Literal Lit = ((Literal)e.Item.FindControl("Lit_cn ")); //Literal Lit_remark = ((Literal)e.Item.FindControl("Lit_remark"));

    1.6K20编辑于 2022-09-14
  • 来自专栏Java架构师必看

    asp.net 2.0中一次性更新所有GRIDVIEW的记录

    GridView1.Rows[i];             SqlDataSource1.UpdateParameters[0].DefaultValue = ((TextBox)row.Cells[0].FindControl TextBox2")).Text;             SqlDataSource1.UpdateParameters[1].DefaultValue = ((TextBox)row.Cells[1].FindControl             GridViewRow row = GridView1.Rows[i];             string value1 = ((TextBox)row.Cells[0].FindControl ("TextBox2")).Text.Replace("'","''");             string value2 = ((TextBox)row.Cells[1].FindControl

    1.5K30发布于 2021-03-22
领券