Dear all,
I have a radgrid like follows:
<telerik:RadGrid ID="uiGrid" runat="server"
AutoGenerateColumns="false" ItemStyle-BackColor="White" AlternatingItemStyle-BackColor="White"
OnDataBound="uiGrid_DataBound" OnItemDataBound="uiGrid_ItemDataBound" OnNeedDataSource="uiGrid_NeedDataSource"
ClientSettings-ClientEvents-OnKeyPress="keyPressInGrid"
Width="100%" Height="500">
<ClientSettings>
<Scrolling CountGroupSplitterColumnAsFrozen="false" AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="3"></Scrolling>
</ClientSettings>
<MasterTableView>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="<%$ Resources:Resource,Group %>" FieldName="IndicatorParentName"></telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="IndicatorParentName" SortOrder="Ascending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<Columns>
<telerik:GridBoundColumn DataField="IndicatorName" HeaderText="<%$ Resources:Resource,Indicator %>" UniqueName="IndicatorName"
SortExpression="IndicatorName" DataType="System.String" ItemStyle-Wrap="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:HiddenField ID="uiIndicatorID" runat="server" Value='<%#Eval("IndicatorID")%>' />
<asp:HiddenField ID="uiIndicatorName" runat="server" Value='<%#Eval("IndicatorName")%>' />
<asp:ImageButton ID="uiTipsButton" runat="server" ImageUrl="images/information-icon.png?20170703" Width="16" Height="16" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="<%$ Resources:Resource,Unit %>">
<ItemTemplate>
<asp:Label ID="uiUnit" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
And I have functions to find controls value like this :
foreach (GridDataItem item in uiGrid.MasterTableView.Items)
{
if (item.ItemType == GridItemType.Item || item.ItemType == GridItemType.AlternatingItem)
{
HiddenField uiIndicatorID = item.FindControl("uiIndicatorID") as HiddenField;
for (int i = 0; i < uiGrid.MasterTableView.Columns.Count; i++)
{
HiddenField uiLocationID = item.FindControl("uiID_" + i.ToString()) as HiddenField;
RadNumericTextBox uiCurrencyBox = item.FindControl("uiCurrencyBox_" + i.ToString()) as RadNumericTextBox;
RadNumericTextBox uiInputBox = item.FindControl("uiInputBox_" + i.ToString()) as RadNumericTextBox;
HiddenField uiRemarksBox = item.FindControl("uiRemarksBox_" + i.ToString()) as HiddenField;
Now I want is not to loop the GridIitem to do the processing, I want to do the processing when user leave each inputbox (inside the grid) event happened. So I added the follows , in the InstantiateIn I add a delegation txt_TextChanged to the TextChanged event of _inputbox.
public void InstantiateIn(System.Web.UI.Control container)
_inputBox = new RadNumericTextBox();
_inputBox.ID = "uiInputBox_" + _controlIDNumber;
_inputBox.Width = Unit.Pixel(100);
UsageEdit ue = new UsageEdit(); //UsageEdit is another class
_inputBox.TextChanged += ue.txt_TextChanged;
So in UsageEdit Class, I have the function
public void txt_TextChanged(object sender, EventArgs e)
{
}
My question is, how can I get the control value in function. like something:
public void txt_TextChanged(object sender, EventArgs e)
{
HiddenField uiIndicatorID = sender.FindControl("uiIndicatorID") as HiddenField;
for (int i = 0; i < uiGrid.MasterTableView.Columns.Count; i++)
{
HiddenField uiLocationID = sender.FindControl("uiID_" + i.ToString()) as HiddenField;
RadNumericTextBox uiCurrencyBox = sender.FindControl("uiCurrencyBox_" + i.ToString()) as RadNumericTextBox;
RadNumericTextBox uiInputBox = sender.FindControl("uiInputBox_" + i.ToString()) as RadNumericTextBox;
HiddenField uiRemarksBox = sender.FindControl("uiRemarksBox_" + i.ToString()) as HiddenField;
}
Can I do that, can I access the control of the grid item in leave event of the inputbox that is in the grid item?