RT

解决方案 »

  1.   

    you can access through the e.Item property, for example
    void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
          {
    TextBox tb = e.Item.FindControl("YourTextBoxID") as TextBox;
    if (tb != null)
    {
    Page.Response.Write(tb.Text);
    }
          }
      

  2.   

    int a=int.Parse(((TextBox)e.Item.FindControl("txtPage")).Text);
    int c=int.Parse(((Label)e.Item.FindControl("lbCountPage1")).Text);
    如果是字符串的话,就不用int.Parse()转换了
      

  3.   

    private void dg_Notice_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    { if (e.CommandName=="commcontent")
    {
    LinkButton lb=e.Item.FindControl("LinkButton2") as LinkButton;
                      //取得模板列中的LINKBUTTON SqlCommand comm=new SqlCommand();
    comm.Connection=this.sqlConn_Notice;
    comm.CommandText="Display_Notice";
    comm.CommandType=CommandType.StoredProcedure;
    comm.Parameters.Add("@NotTitle",SqlDbType.VarChar,100,"NotTile");
    comm.Parameters.Add("@NotContent",SqlDbType.VarChar,4000,"NotContent");

    comm.Parameters["@NotTitle"].Value=lb.Text;
             //将LINKBUTTON的TEXT属性值传给参数 comm.Parameters["@NotContent"].Direction=ParameterDirection.Output; this.sqlConn_Notice.Open();
    int i=comm.ExecuteNonQuery();
    ElectSite.NotContent.content=comm.Parameters["@NotContent"].Value.ToString();
    this.sqlConn_Notice.Close(); Response.Redirect("NotContent.aspx",true);
    }
    }
    按照思归的说法应该是这样做了吧,但是这样还是不能取出LINKBUTTON的TEXT属性值啊?
      

  4.   

    how does your template look like??<asp:LinkButton CommandName='commcontent' runat="server" id="LinkButton2" Text='<%# ... %>' />
      

  5.   

    To Saucer:
    No...
    Just like this:
    <asp:LinkButton CommandName='commcontent' runat="server" id="LinkButton2">
    <%#...%></LinkButton>
    Is that right?
      

  6.   

    no, then <%#...%> became a child control of LinkButton,and of DataBoundLiteralControl type, use my method<asp:LinkButton CommandName='commcontent' runat="server" id="LinkButton2" Text='<%# ... %>' />
    or you have to doDataBoundLiteralControl dlc = LinkButton2.Controls[0] as DataBoundLiteralControl;
    Response.Write(dlc.Text);
      

  7.   

    Ok,I got it.
    thank Saucer very much.In fact,I have already solved this problem,but with another method.Because I thought that method is not good enough,then I resorted to CSDN for a better way.