Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
165 views
How to send data to database using checkbox in radgrid while the submit button is in the other form or page
Eyup
Telerik team
 answered on 31 Jan 2020
1 answer
630 views

I currently have a RadGrid (MainGrid) that contains a Template Column. This Template Column itself contains a separate RadGrid (SubGrid).

 

The MainGrid has an EditFormTemplate in which I have an ASP.NET PlaceHolder. During MainGrid's ItemCreated event, I check to make sure the Item is in EditMode, instantiate a new RadGrid, and make this new RadGrid equal to the SubGrid (SubGridEdit). During runtime, SubGridEdit displays perfectly fine with all of the correct columns and data, but any attempt during the MainGrid's ItemCommand or UpdateCommand events to access the data rows fails. Everything appears to be fine, but the application is reporting that SubGridEdit has 0 items in its collection. 

 

During MainGrid's ItemCreated event, I have verified that SubGridEdit (a copy of SubGrid that is added to my Placeholder) contains Items in its collection, but once the application moves to the UpdateCommand or ItemCommand events for MainGrid, I'm lost. I'm able to access SubGridEdit by using the FindControl method of the GridEditableItem/GridDataItem, but it's reporting no Items in its collection despite them clearly being displayed.

 

 

In essence, SubGrid contains data that is tied to each record in MainGrid. Editing MainGrid involves also editing SubGrid. In this case, SubGrid contains a few checkboxes that the user should be able to mark or unmark while editing MainGrid. In order to do so, though, I need to be able to access the controls of the RadGrid inside of the EditFormTemplate. Any pointers?

Here's the ItemDataBound and ItemCreated events for the MainGrid and the relevant ASPX (Names/IDs changed to examples for security purposes)

protected void gvOptionsPOP_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem && !e.Item.IsInEditMode)
    {
        GridDataItem item = (GridDataItem)e.Item;
        RadGrid test123 = (RadGrid)item.FindControl("gvRequirements");
        int id = Convert.ToInt32(item["OptionYearID"].Text);
        string _URLAuthority = Request.Url.Authority;
        string _URLScheme = Request.Url.Scheme;
         
        if (_URLAuthority.Contains("localhost"))
        {
            _URLAuthority = _URLAuthority.Replace(Request.Url.Authority, "exampleurl");
        }
        if (_URLScheme == "http")
        {
            _URLScheme = "https";
        }
         
        string _baseURL = _URLScheme + "://" + _URLAuthority + "/SRTD";
        test123.DataSource = ExampleClass.GetData(id, _baseURL);
        test123.Rebind();
 
        CheckBox chk = (CheckBox)item["OptionExecute"].Controls[0];
        LinkButton lnkbutton = (LinkButton)item["EditPOP"].Controls[0];
         
        lnkbutton.Enabled = false;
 
        if (item.ItemIndex == 0 && chk.Checked)
        {
            lnkbutton.Enabled = true;
        }
        else if (chk.Checked)
        {
            foreach (GridDataItem test1 in gvOptionsPOP.Items)
            {
                CheckBox chk2 = (CheckBox)test1["OptionExecute"].Controls[0];
                LinkButton lnkbutton2 = (LinkButton)test1["EditPOP"].Controls[0];
                if (chk2.Checked)
                {
                    lnkbutton2.Enabled = false;
                }
            }
            lnkbutton.Enabled = true;
        }
    }
}
 
protected void gvOptionsPOP_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditFormItem editedItem = (GridEditFormItem)e.Item;
        GridDataItem originalItem = editedItem.ParentItem;
         
        RadGrid test123 = (RadGrid)originalItem.FindControl("gvRequirementsPOP");
        PlaceHolder editPanel = (PlaceHolder)editedItem.FindControl("pnlPlaceHolder");
 
        RadGrid test456 = test123;
 
        foreach (GridDataItem dataItem in test123.Items)
        {
            CheckBox chkbox = (CheckBox)dataItem["CheckboxTemplate"].FindControl("RequirementExecute");
            chkbox.Enabled = true;
        }
 
        test456.Rebind();
    }
}
<telerik:RadGrid ID="gvOptionsPOP" runat="server"
AllowPaging="false"
PageSize="20"
AllowSorting="false"
ShowFooter="false"
ShowStatusBar="false"
AutoGenerateColumns="false"
OnNeedDataSource="gvOptionsPOP_NeedDataSource"
OnItemCommand="gvOptionsPOP_ItemCommand"
OnItemCreated="gvOptionsPOP_ItemCreated"
OnUpdateCommand="gvOptionsPOP_UpdateCommand"
OnItemDataBound="gvOptionsPOP_ItemDataBound"
Width="80%"
GridLines="Both"
ItemStyle-BorderStyle="Solid">
 
    <ClientSettings EnableRowHoverStyle="true"
       EnablePostBackOnRowClick="false" />
 
    <MasterTableView AllowFilteringByColumn="false"
       ShowFooter="false"
       ShowHeadersWhenNoRecords="true" BorderStyle="Solid">
 
       <EditFormSettings EditFormType="Template">
              <FormTemplate>
                     <br />
                     <asp:PlaceHolder ID="pnlPlaceHolder" runat="server" />
                     <br />
                     <span>
                            <asp:Button runat="server" ID="btnUpdate" Text="Update" CommandName="Update" />
                            <asp:Button runat="server" ID="btnCancel" Text="Cancel" CommandName="Cancel" />
                     </span>
              </FormTemplate>
       </EditFormSettings>
 
       <NoRecordsTemplate>
              <div>NO OPTIONS FOUND.</div>
       </NoRecordsTemplate>
 
       <Columns>
              <telerik:GridButtonColumn UniqueName="EditPOP" CommandName="Edit" Text="Edit" />
              <telerik:GridBoundColumn UniqueName="OptionYearID" DataField="options_id" HeaderText="Option Year ID" ItemStyle-HorizontalAlign="Center" Display="false" HeaderStyle-HorizontalAlign="Center" />
              <telerik:GridBoundColumn UniqueName="OptionYear" DataField="option_period" HeaderText="Option Year" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
              <telerik:GridDateTimeColumn UniqueName="POPStart" DataField="option_award_date" HeaderText="Proposed/Actual Start Date" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
              <telerik:GridDateTimeColumn UniqueName="POPEnd" DataField="option_end_date" HeaderText="Proposed/Actual End Date" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
              <telerik:GridTemplateColumn UniqueName="RequirementTemplate" HeaderText="Requirement/CSA#" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
              <ItemTemplate>
                     <telerik:RadGrid ID="gvRequirementsPOP" runat="server"
                     AllowPaging="false"
                     PageSize="20"
                     AllowSorting="false"
                     ShowFooter="false"
                     ShowStatusBar="false"
                     AutoGenerateColumns="false"
                     OnItemDataBound="gvRequirementsPOP_ItemDataBound"
                     Width="100%"
                     ItemStyle-BorderStyle="Solid">
 
                     <ClientSettings EnableRowHoverStyle="true"
                            EnablePostBackOnRowClick="false" />
 
                     <MasterTableView AllowFilteringByColumn="false"
                            ShowFooter="false"
                            ShowHeadersWhenNoRecords="true" BorderStyle="Solid" DataKeyNames="ReqCSA, EXECUTION_FLAG">
 
                            <NoRecordsTemplate>
                                   <div>NO REQUIREMENTS FOUND.</div>
                            </NoRecordsTemplate>
 
                            <Columns>
                                   <telerik:GridBoundColumn UniqueName="RequirementsID" DataField="Requirements_ID" HeaderText="Requirements ID" Display="false" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
                                   <telerik:GridBoundColumn UniqueName="ExecutionFlag" DataField="EXECUTION_FLAG" HeaderText="Execution Flag" Display="false" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
                                   <telerik:GridHyperLinkColumn UniqueName="ReqLink" DataTextFormatString="{0}" DataNavigateUrlFields="ReqLink" DataNavigateUrlFormatString="{0}" DataTextField="ReqCSA" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="SCA#"  ItemStyle-Width="25%" HeaderStyle-Width="25%" />
                                   <telerik:GridTemplateColumn UniqueName="CheckboxTemplate" HeaderText="Execute" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%" HeaderStyle-Width="25%" >
                                          <ItemTemplate>
                                                 <asp:CheckBox ID="RequirementExecute" runat="server" Text="Execute" />
                                          </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridBoundColumn UniqueName="RequirementType" DataField="REQUIREMENT_TYPE" HeaderText="Type" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%" HeaderStyle-Width="25%" />
                                   <telerik:GridBoundColumn UniqueName="RequirementStatus" DataField="REQUIREMENT_Status" HeaderText="Status" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%" HeaderStyle-Width="25%" />
                            </Columns>
                            </MasterTableView>
                     </telerik:RadGrid>
              </ItemTemplate>
              </telerik:GridTemplateColumn>
              <telerik:GridCheckBoxColumn UniqueName="OptionExecute" DataField="EXECUTION_FLAG" HeaderText="Option Execute" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
       </Columns>
    </MasterTableView>
</telerik:RadGrid>
Eyup
Telerik team
 answered on 30 Jan 2020
0 answers
54 views

I open a child radwindow popup from parent radwindow popup. This works quite good but client wants to move child/second radwindow popup outside the boundaries of parent/first radwindow popup. I used following code to open the child/second popup in the parent page of first radwindow popup:

GetRadWindow().BrowserWindow;

It opens the child/second radwindow popup in the page but it closes the parent/first radwindow popup.

Please suggest a solution to solve this issue and achieve the requirement.

 

 

mohinder
Top achievements
Rank 1
 asked on 30 Jan 2020
2 answers
316 views

Hi,

I would like to use some Awesome Font icons instead of using the ImageUrl attribute, is this possible? I noticed that this seems possible on a normal RadButton but the same implementation does not seem to work on a RibbonBarButton. Ideas, or is this just not possible on a RibbonBarButton?

 

Thanks,
Gary Kearney

Peter Milchev
Telerik team
 answered on 29 Jan 2020
2 answers
76 views

I have Grouping set to True but do not know how to add a field to it during design time or in the page load event.

MSQ
Top achievements
Rank 1
 answered on 29 Jan 2020
10 answers
2.5K+ views
I am using a <FilterTemplate> in a <telerik:GridTemplateColumn> for which I have this DropDownList:

<

 

asp:DropDownList ID="ddlEntityTypeFilter" runat="server" AutoPostBack="true"

 

 

 

OnSelectedIndexChanged="ddlEntityTypeFilter_SelectedIndexChanged">

 

 

 

I have succeeded in getting the postback to work correctly so that the RadGrid is updated after a telRadGrid.Rebind().
And everything seems to work EXCEPT the DropDownList does NOT persist the SelectedIndex. I can retain the SelectedIndex in a session variable, but I have not been able to reset the SelectedIndex so that it shows the correct index that was selected for the postback.

Which DropDownList event, and/or RadGrid event, and/or Page event should I be using? Any code to show how to do this would be most appreciated. Thanks.

Alan
Top achievements
Rank 1
 answered on 29 Jan 2020
5 answers
296 views

Hello,

We recently moved to Azure, and in our staging environments, we have had repeated 502 errors when attempting to export to excel from a radgrid.

Restarting the app allows export to be used again for some time. 

I've read some forums that seemed to have similar issues, but not exactly. Was wondering if there was a common fix for this issue that i missed somewhere.

 

Thanks for your help!

Attila Antal
Telerik team
 answered on 29 Jan 2020
9 answers
565 views
Hi,

I have a RadNumericTextBox with an empty message "VEHICLE NUMBER". Upon insertion of vehicle number and other fields user can click on the Update button which causes a post back. The first time the page loads the update button doesn't validate input fields like the vehicle number and causes a post back which is the intended functionality.

However, when I type some number and delete it at the same time the Update button validates the  Vehicle Number RadNumericTextBox.
If I remove the empty message or put a numeric value to the empty massage then the update button works as usual.

It seems that the RadNumericTextBox conflicts with its own EmptyMessage which is not necessarily be a number.

How to avoid this?

Thanks

 
Qing
Top achievements
Rank 1
 answered on 29 Jan 2020
3 answers
248 views
I have tried to change the ForeColor and BackColor of a RACB token, but the styling doesn't appear when i add the tokens. Is it not possible to change the colors from code-behind?

Here is my code:

          
foreach (string chemical in chemicalsArrayList)
{
    AutoCompleteBoxEntry entry = new AutoCompleteBoxEntry();
    chemicalBC = BCFactory.ChemicalBC;
    DataSet dsClassifications = chemicalBC.GetClassificationByChemicalName(chemical);
    entry.Text = chemical;
    if (dsClassifications.Tables[0].Rows.Count != 0)
    {
        entry.ToolTip = dsClassifications.Tables[0].Rows[0][0].ToString();
        entry.ForeColor = System.Drawing.ColorTranslator.FromHtml("#" + dsClassifications.Tables[0].Rows[0]["Color"].ToString());
    }
    else
    {
        entry.ToolTip = "";
    }
 
    racbChemicals.Entries.Add(entry);
}
Peter Milchev
Telerik team
 answered on 28 Jan 2020
1 answer
129 views
Is there a way to select and upload multiple files at once from smartphone, ex. Android?
Vessy
Telerik team
 answered on 27 Jan 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?