C# .NET - how to convert Hiddenfield value

Asked By raj kumar
10-Feb-12 09:49 AM
HiddenField hfNotConfirmItem =e.Row.Cells[0].FindControl("hfNotConfirmItem") as HiddenField;
        if (hfNotConfirmItem==0))
          btnConfirm.Enabled = true;
        else
          btnConfirm.Enabled = false;


This Code is not working
  Suchit shah replied to raj kumar
10-Feb-12 10:08 AM
you have to check with value property

HiddenField hfNotConfirmItem =e.Row.Cells[0].FindControl("hfNotConfirmItem") as HiddenField;
      if (hfNotConfirmItem.value==0))
      btnConfirm.Enabled = true;
      else
      btnConfirm.Enabled = false;
  kalpana aparnathi replied to raj kumar
10-Feb-12 12:57 PM
hi,

First of all you can check the data what come in the hiddenfield

1) int no = Convert.Int(hidden_field.Value.TrimStart());

2) int no = 0;

 if(!int.TryParse(hidden_field.Value.TrimStart(),out no)

{

    Response.Write("hidden field value is not parse as a int");

}
  Sandeep Mittal replied to raj kumar
10-Feb-12 11:25 PM
HiddenField hfNotConfirmItem =e.Row.Cells[0].FindControl("hfNotConfirmItem") as HiddenField;
if (hfNotConfirmItem.value=="0"))
   btnConfirm.Enabled = true;
else
   btnConfirm.Enabled = false;
Create New Account
help
how to find second row hiddenfield value hi friends, this my coding. . . . protected void grvddlPayment_SelectedIndexChanged( object sender, EventArgs e) { GridViewRow selectedRow = ( GridViewRow )(( DropDownList )sender).NamingContainer; int rowindex = selectedRow.RowIndex; DropDownList grvddlPayment = ( DropDownList )dgvPayment.Rows[rowindex].FindControl( "grvddlPayment" ); / / HiddenField grvhifBankPaymentKey = (HiddenField)dgvPayment.Rows[rowindex].FindControl("hifBankPaymentKey"); if (grvddlPayment.SelectedItem.Text ! = "- -Others- -" ) { if (dgvPayment.Rows.Count > 0) { foreach ( GridViewRow grv in Rows) { int index = grv.RowIndex; if (rowindex ! = Convert .ToInt32(grv.RowIndex)) { System.Web.UI.WebControls. HiddenField grvhifBankPaymentKey1 = (System.Web.UI.WebControls. HiddenField )grv.Cells[0].FindControl( "hifBankPaymentKey" ); if (grvddlPayment.SelectedItem.Value = = grvhifBankPaymentKey1.Value.ToString()) { strMsg = "Payment Name Already Exist" ; ScriptManager .RegisterStartupScript
on Row DataBOund Event - -- -- -- - if (e.Row.RowType = = DataControlRowType.DataRow) { HtmlInputText htmlTxt = (HtmlInputText)e.Row.FindControl("txtQty"); Label lblgvCartProdID = (Label)e.Row.FindControl("lblCartProdID"); HiddenField hidPreviousQty = (HiddenField)e.Row.FindControl("hidPreviousQty"); string strjavascript; strjavascript = "javascript:validateQty(" + htmlTxt.ClientID + ", " + hidPreviousQty.ClientID + ", " + lblgvCartProdID.Text + ");"; htmlTxt.Attributes.Add i < e.Row.Cells.Count-1; i++) { evtHandler = "updateValue(" + GridView1.ClientID + ", " + rowIndex + ")"; ((TextBox)e.Row.FindControl("TextBox"+i.ToString())).Attributes.Add("onblur", evtHandler); } } } forums. asp . net / t / 1101815. asp x http Hi, Check this code. if (e.Row.RowType = = DataControlRowType.DataRow) { HtmlInputText htmlTxt = (HtmlInputText)e.Row.FindControl("txtQty"); Label lblgvCartProdID = (Label)e.Row.FindControl("lblCartProdID"); HiddenField hidPreviousQty = (HiddenField)e.Row.FindControl("hidPreviousQty"); string strjavascript; strjavascript = "validateQty(" + htmlTxt.ClientID + ", " + hidPreviousQty
FindControl is terible to use and maintain .NET Framework I'm this far in determining the correct code to find a textbox I need to set. Me.Master.FindControl("Body1").FindControl("Form2").FindControl("Table2").FindControl("TableRow7").FindControl("TableCellR7C2S2").FindControl("RightCPH").FindControl("div1").FindControl("div2").FindControl("LoginView1") Took me longer than I want to say to produce