This is a migrated thread and some comments may be shown as answers.

can not get value from template field

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
niloofar
Top achievements
Rank 1
niloofar asked on 19 Sep 2010, 12:46 PM
hi
i  have template field (twextbox) into radgrtid
i type value in textbox ,but when i get value ,show ""

    <telerik:GridTemplateColumn HeaderText="شماره سند" FilterControlWidth="10px" UniqueName="AccountingDoc1">
                        <ItemTemplate>
                        <asp:TextBox ID="txtAccountingDoc"  runat="server" >
                        </asp:TextBox>
                        
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>


*****************************************************************************************************************************

  protected void grdDetailAccount_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {

            e.Canceled = true;
            foreach (GridDataItem item in grdDetailAccount.Items)
            {

                string detailAccountID = grdDetailAccount.MasterTableView.DataKeyValues[e.Item.ItemIndex]["detailAccountID"].ToString();
          

                if (((TextBox)item["AccountingDoc1"].FindControl("txtAccountingDoc")).Text != "")
                {
                    strAccountingDocNo = ((TextBox)item["AccountingDoc1"].FindControl("txtAccountingDoc")).Text;
                    CDSStockLogic.BusinessObjects.UI.AccountingDocs.updateDetailAccountID(strAccountingDocNo, detailAccountID);
                }
            }
        }

strAccountingDocNo  is null but i type value
plz help

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2010, 08:18 AM
Hello Niloofar,

I have not found any issue when i tried the same code in my end. I am not sure when you are invoking the ItemCommand event and how. Here is my scenario:

Markup:
<CommandItemTemplate>
      <asp:Button ID="Button1" runat="server" Text="Button" CommandName="click" />
</CommandItemTemplate>

Code Behind:
protected void grdDetailAccount_ItemCommand1(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == "click")
        {
            e.Canceled = true;
            foreach (GridDataItem item in grdDetailAccount.Items)
            {
                      
if(((TextBox)item["AccountingDoc1"].FindControl("txtAccountingDoc")).Text != "")
                 {
                    string  strAccountingDocNo = ((TextBox)item["AccountingDoc1"].FindControl("txtAccountingDoc")).Text;
                 }
            }
         }         
    }

Could you paste the complete code/give some more information about your scenario, if this does not help?

Regards,
Shinu.
Tags
Grid
Asked by
niloofar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or