2015-09-14 52 views
1
內工作

有一個RadGrid其內部存在 EditItemTemplate一個RadComboBoxasp ButtonRadButton - 單點擊的方式,而不是radgrid控件的EditItemTemplate中

下面是當前的代碼:

<telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code"> 
    <ItemTemplate> 
     <asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("AccountCode")%>'></asp:Label> 
    </ItemTemplate> 
    <EditItemTemplate> 

     <telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240" DropDownWidth="310"  
     EnableLoadOnDemand="True" OnItemsRequested="ddlAccountCode_ItemsRequested" EnableItemCaching="true" 
     ShowMoreResultsBox="True" EnableVirtualScrolling="true" AllowCustomText="true" MarkFirstMatch="true" 
     Filter="Contains" HighlightTemplatedItems="true" CausesValidation="true" AppendDataBoundItems="true" 
     DataTextField="AccountDescription" DataValueField="AccountCodeID" 
     ShowDropDownOnTextboxClick="false" 
     OnClientDropDownOpening="OnClientDropDownOpening" OnClientItemsRequested="OnClientItemsRequested" 
     OnClientTextChange="LoadECnEntityKeys" /> 

     <asp:Button ID="btnSearch" runat="server" Text="Search" OnClient="btnSearch_Click" /> 
     &nbsp; 
     <asp:Label ID="lblMsg" runat="server" Visible="false"></asp:Label> 

    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

protected void btnSearch_Click(object sender, EventArgs e) 
{ 
    Response.Write("Default.aspx"); 
    //other code 
} 

當我鍵入內部RadComboBox東西鍵入/,點擊asp Button, 則只有OnClick執行後,有關鍵入的文本啓動和顯示搜索事件asp Button

現在,新的要求來到了RadButton(帶 - 單擊 的方法),以取代asp Button,以避免雙擊。

問題是:當我實現RadButton內radgrid控件的EditItemTemplateRadButton從來沒有回傳,即,當我點擊它沒有任何反應。 但是當我在RadGrid以外使用RadButton時,工作正常。

下面是使用代碼RadButton(帶 - 單點擊 方法):

<telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code"> 
    <ItemTemplate> 
     <asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("AccountCode")%>'></asp:Label> 
    </ItemTemplate> 
    <EditItemTemplate> 

     <telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240" DropDownWidth="310"  
     EnableLoadOnDemand="True" OnItemsRequested="ddlAccountCode_ItemsRequested" EnableItemCaching="true" 
     ShowMoreResultsBox="True" EnableVirtualScrolling="true" AllowCustomText="true" MarkFirstMatch="true" 
     Filter="Contains" HighlightTemplatedItems="true" CausesValidation="true" AppendDataBoundItems="true" 
     DataTextField="AccountDescription" DataValueField="AccountCodeID" 
     ShowDropDownOnTextboxClick="false" 
     OnClientDropDownOpening="OnClientDropDownOpening" OnClientItemsRequested="OnClientItemsRequested" 
     OnClientTextChange="LoadECnEntityKeys" /> 

     <telerik:RadButton runat="server" ID="btnSearch" Text="Search" SingleClick="true" 
     SingleClickText="Submitting..." OnClick="btnSearch_Click" /> 
     &nbsp; 
     <asp:Label ID="lblMsg" runat="server" Visible="false"></asp:Label> 

    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

protected void btnSearch_Click(object sender, EventArgs e) 
{ 
    Response.Write("Default.aspx"); 
    //other code 
} 

請讓我知道這是爲什麼hapenning? 請不要回復

在此先感謝

+0

有任何JavaScript錯誤可以檢查你的控制檯瀏覽器中瀏覽器調試器? – Nic

回答

1

我會建議你使用的CommandName作爲按鈕的事件。無論如何,這裏是我的代碼...我嘗試使用OnClick和CommandName它工作得很好。我懷疑你的錯誤將是某種形式的javascript ...

的.aspx

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Width="100%" 
OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand" 
OnItemDataBound="RadGrid1_ItemDataBound"> 
<MasterTableView EditMode="InPlace"> 
    <Columns> 
     <telerik:GridTemplateColumn> 
      <ItemTemplate> 
       <asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("T")%>'></asp:Label> 
      </ItemTemplate> 
      <EditItemTemplate> 
       <telerik:RadComboBox ID="rcb" runat="server" AllowCustomText="true"> 
       </telerik:RadComboBox> 
       <telerik:RadButton runat="server" ID="btnSearch" Text="Search" 
       SingleClick="true" SingleClickText="Submitting..." CommandName="Search" /> 
      </EditItemTemplate> 
     </telerik:GridTemplateColumn> 
     <telerik:GridTemplateColumn> 
      <ItemTemplate> 
       <telerik:RadButton ID="btnEdit" runat="server" 
       Text="Edit" CommandName="Edit"></telerik:RadButton> 
      </ItemTemplate> 
      <EditItemTemplate> 
       <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel" 
       CommandName="Cancel"></telerik:RadButton> 
      </EditItemTemplate> 
     </telerik:GridTemplateColumn> 
    </Columns> 
</MasterTableView> 

的.cs

protected void Page_Load(object sender, EventArgs e) 
{ 
    // Check 
    if (!IsPostBack) 
    { 
     // Variable 
     DataTable dt = new DataTable(); 
     dt.Columns.Add("T"); 

     // Loop & Add 
     for (int i = 0; i < 10; i++) 
      dt.Rows.Add(i + ""); 

     // Check & Bind 
     if (dt != null) 
     { 
      ViewState["Grid"] = dt; 

      RadGrid1.DataSource = dt; 
      RadGrid1.DataBind(); 

      // Dispose 
      dt.Dispose(); 
     } 
    } 
} 

protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
{ 
    RadGrid1.DataSource = ViewState["Grid"] as DataTable; 
} 

protected void btnSearch_Click(object sender, EventArgs e) 
{ 
    Response.Write("GG"); 
} 

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) 
{ 
    // Check 
    if (e.CommandName == "Search") 
    { 
     // Variable 
     GridEditableItem item = e.Item as GridEditableItem; 
     string something = ""; 

     // Find Control 
     RadComboBox rcb = item.FindControl("rcb") as RadComboBox; 

     // Check 
     if (rcb != null) 
     { 
      // Set 
      something = rcb.Text; 

      // Do Something 

      Response.Write(something); 
     } 
    } 
} 

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
{ 
    // Check 
    if (e.Item is GridEditableItem) 
    { 
     // FindControl 
     RadComboBox rcb = e.Item.FindControl("rcb") as RadComboBox; 

     // Check 
     if (rcb != null) 
     { 
      rcb.DataSource = ViewState["Grid"] as DataTable; 
      rcb.DataTextField = "T"; 
      rcb.DataValueField = "T"; 
      rcb.DataBind(); 
     } 
    } 
} 
相關問題