Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
955 views

I have an auto-generated radgrid bound to a table.  In Edit Mode, in the code-behind, I have successfully created a drop-down list to replace the default a textbox for ONE column.

This drop down list pulls its list items from a second table and data source.  The FAILURE POINT is that the selected item from the drop down list is not SAVED to the subject tablet record.  The other columns will update and save properly.  

The code behind that WORKS for creating the substitute drop-down is here, with my notation as to where I am GUESSING I need to do something correctly.  I have tried every possible forum suggestion, but the source of my pain is that the value in the drop-down list is not being passed to the actual column value on update.  Been stuck for several hours on this one. Probably something silly that I will kick myself for, but not the first time. 

<p></p>protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         GridEditableItem edit = (GridEditableItem)e.Item;
         edit["EmployeeRecordID"].Visible = false;
                   
  
  
         SqlConnection con = new SqlConnection(MasterConnectionString);
         String queryString = "SELECT GroupLabel From Groups";
         con.Open();            
         SqlDataAdapter dr = new SqlDataAdapter(queryString, con);
         DataTable dt = new DataTable();
         dr.Fill(dt);
         con.Close();
  
         ddledit = (GridEditableItem)e.Item;
         txt = (TextBox)ddledit["GroupAssociation"].Controls[0];
         //txt.Visible = false;                    
         DropDownList droplist = new DropDownList();            
         droplist.DataSource = dt;
         droplist.DataTextField = "GroupLabel";
         droplist.DataValueField = "GroupLabel";
         droplist.DataBind();
         ddledit["GroupAssociation"].Controls.Add(droplist);
         
  
                                
                 
     }
 }
  
 protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     //this is where I THINK my failure point is, but not sure.      
 }
Eyup
Telerik team
 answered on 24 Sep 2019
1 answer
142 views

Hi,

we have an application that uses the RadGrid. 

Our customer has set compatibility mode for the entire domain (evidently through group policy). 
In compatibility mode our application has rendering problems, so we added the directive <add name = "X-UA-Compatible" value = "IE = edge" /> in IIS to force IE11 to work in standard mode.

Now we have a problem: the radgrid shows the header not correctly aligned with the content of the grid.

It seems that bringing IE from compatibility mode to standard mode is not the same as working directly in standard mode.

Did you experienced this kind of problem?

Thanks in advance for the support

 

Attila Antal
Telerik team
 answered on 24 Sep 2019
2 answers
173 views

I am converting an old application that stores its images as base64strings in a SQL Server database.

I am trying to add the images to the gallery. Pointing the ImageURL to a base64 string works fine, but not the ThumbnailURL.

        public static string ImageToBase64(System.Drawing.Image image, System.Drawing.Imaging.ImageFormat format)

        {
            string returnString = "";
            System.IO.MemoryStream ms = new MemoryStream();

            image.Save(ms, format);
            byte[] imageBytes = ms.ToArray();
            returnString = "data:image;base64," + Convert.ToBase64String(imageBytes);

            return returnString;
        }

        public static Telerik.Web.UI.ImageGalleryItem ImageBase64(byte[] BlobData, string ImageTitle)
        {
            Telerik.Web.UI.ImageGalleryItem returnImage = new Telerik.Web.UI.ImageGalleryItem();

            System.Drawing.Image img = null;
            System.IO.MemoryStream mem = new MemoryStream();
            mem.Write(BlobData, 0, BlobData.Length);
            mem.Seek(0, SeekOrigin.Begin);

            img = System.Drawing.Image.FromStream(mem);

            returnImage.Title = ImageTitle;
            returnImage.ThumbnailUrl = ImageToBase64(SizedImage(img, 100, 75), System.Drawing.Imaging.ImageFormat.Jpeg);
            returnImage.ImageUrl =     ImageToBase64(SizedImage(img, 800, 600), System.Drawing.Imaging.ImageFormat.Jpeg);
            return returnImage;
        }

        returnImage.ImageUrl works perfectly fine.

 


        public static System.Drawing.Bitmap SizedImage(System.Drawing.Image img, int dispWidth, int dispHeight)
        {
            double scale = 1.0, hScale = 1.0;
            double imgWidth = img.Width;
            double imgHeight = img.Height;

            if (imgWidth > dispWidth)
                scale = dispWidth / imgWidth;
            if (imgHeight > dispHeight)
                hScale = dispHeight / imgHeight;
            if (hScale < scale)
                scale = hScale;

            int imgw = Convert.ToInt32(imgWidth * scale);
            int imgh = Convert.ToInt32(imgHeight * scale);

            return new System.Drawing.Bitmap(img, imgw, imgh);
        }

Richard
Top achievements
Rank 1
 answered on 23 Sep 2019
3 answers
970 views
I create the grid below:
<telerik:RadGrid runat="server" ID="grdImportData" RenderMode="Lightweight" AllowPaging="true" PageSize="10" OnNeedDataSource="grdImportData_NeedDataSource" OnPageIndexChanged="grdImportData_PageIndexChanged" OnUpdateCommand="grdImportData_UpdateCommand" OnDeleteCommand="grdImportData_DeleteCommand" OnItemCommand="grdImportData_ItemCommand"  OnItemDataBound="grdImportData_ItemDataBound" AllowSorting="False" AlternatingItemStyle-BackColor="#f5f5f5" ItemStyle-BackColor="#ffffff" ColumnWidth="Auto" HorizontalAlignment="Stretch" Width="100%">
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="1" EnableVirtualScrollPaging="true"></Scrolling>
                <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" EnableRealTimeResize="true" />
        </ClientSettings>
    <MasterTableView EditMode="InPlace" DataKeyNames="Id">
        <Columns>
            <telerik:GridEditCommandColumn  HeaderStyle-Width="75px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"/>
            <telerik:GridTemplateColumn HeaderStyle-Width="50px">
                <ItemTemplate>
                    <asp:LinkButton runat="server" CommandName="Delete"><i class="icon s7-junk grid-edit-icon"></i></asp:LinkButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

I then try to add a TemplateColumn, EditTemplateColumn and RadDropdownlist programmatically like below:

protected void grdImportData_ItemDataBound(object sender, GridItemEventArgs e)
{
    if(ImportType == "CLEARGISTIX_ASSETS")
    {
        if (e.Item is GridDataItem)
        {
            string templateColumnName = "AssetTypeName";
            GridTemplateColumn templateColumn = new GridTemplateColumn();
            templateColumn.ItemTemplate = new MyTemplate(templateColumnName);
            templateColumn.EditItemTemplate = new MyEditTemplate();
            templateColumn.HeaderText = templateColumnName;
            templateColumn.DataField = "AssetTypeName";
 
            if (e.Item.IsInEditMode)
            {
                RadDropDownList rddl = new RadDropDownList();
                PortalView.LookupListBO list = LookupListBA.LookupList_GetByKey(DB_Context, "SITE_ASSETTYPE_LIST", UtilityBA.IsActiveChoice.Active);
                List<PortalView.LookupListItemBO> oList = LookupListBA.LookupListItem_GetList_ByLookupListId(DB_Context, list.LookupListId, (Guid)Current.Employee.SiteId);
                rddl.ID = "dropdownlist1";
                rddl.DataSource = oList;
                rddl.DataTextField = "Name";
                rddl.DataValueField = "LookupListItemId";
            }
            grdImportData.MasterTableView.Columns.Add(templateColumn);
        }
    }
}
public class MyTemplate : ITemplate
{
    private string colname;
    protected Label lControl;
    public MyTemplate(string cName)
    {
        colname = cName;
    }
    public void InstantiateIn(System.Web.UI.Control container)
    {
        lControl = new Label();
        lControl.ID = "lControl";
        lControl.DataBinding += new EventHandler(lControl_DataBinding);
        container.Controls.Add(lControl);
    }
 
    public void lControl_DataBinding(object sender, EventArgs e)
    {
        Label l = (Label)sender;
        GridDataItem container = (GridDataItem)l.NamingContainer;
        l.Text = ((DataRowView)container.DataItem)[colname].ToString() + "<br />";
    }
}
 
public class MyEditTemplate : IBindableTemplate
{
    public void InstantiateIn(Control container)
    {
        GridEditFormItem item = ((GridEditFormItem)(container.NamingContainer));
        RadDropDownList drop = new RadDropDownList();
        drop.ID = "dropdownlist1";
 
        container.Controls.Add(drop);
    }
    public System.Collections.Specialized.IOrderedDictionary ExtractValues(System.Web.UI.Control container)
    {
        OrderedDictionary od = new OrderedDictionary();
        od.Add("LookupListItemId", ((RadDropDownList)(((GridEditFormItem)(container)).FindControl("dropdownlist1"))).DataValueField);
        return od;
    }
}

 

When I click on the edit button, I error: 'Unable to cast object of type 'Telerik.Web.UI.GridDataItem' to type 'Telerik.Web.UI.GridEditFormItem'.' on this line:

od.Add("LookupListItemId", ((RadDropDownList)(((GridEditFormItem)(container)).FindControl("dropdownlist1"))).DataValueField);

I notice that it never his the InstaniateIn code at all.

Any assistance is greatly appreciated.

Attila Antal
Telerik team
 answered on 23 Sep 2019
4 answers
384 views
Dears,
I have two comboboxes in page with RadAjaxManager, in the page Load event I hide one of them. I add the following:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="cmbHR_DOCS_ID_START" UpdatePanelRenderMode="Inline" />
                   <telerik:AjaxUpdatedControl ControlID="cmbHR_DOCS_ID" UpdatePanelRenderMode="Inline" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
   </telerik:RadAjaxManager>

When user add a new value two one of the comboes (in a RadWindow) I refresh the data in them by calling:
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(x);

Because one of the combos is invisible I got an ajax error (I think you know).
I know that I can't add two RadAjaxManager in one page so I tried to add AjaxUpdatedControl to the RadAjaxManager at runtime in the Page Load event but it didn't work.

Could you please help in?
Best Regards
Eyup
Telerik team
 answered on 23 Sep 2019
12 answers
1.7K+ views
I want to add Rad Grid Dynamically using Code Behind.with Dynamic Columns 1 Columns should be Drop Down , 1 Column Should be Date picker, 1 Column Should be Text field.these Dynamic Columns should be Shown in Edit mode when Edit button is Clicked.while Showing Data just Data should be shown like data in label.
how can it be possible.
Attila Antal
Telerik team
 answered on 23 Sep 2019
6 answers
810 views
Hi All,

My question for client side code only using JavaScript.
I have a RadDropDownTree in my Form. In that DropDown I have some some data.
Suppose.
Central
    Middle Central
            Chicago
    Texoma
..
.
.
above mention is same data.

Now What I want is when User Select Chicago then Select text in client area of that dropdown should be anything like 'ABCD' or anything. I just want to set the
Selected text of that DropDownTree. I tried below mention code but is not working, In my RadDropDownTree, it still showing emptymessage.

var combo = $find("<%= RadDropDownLocations.ClientID %>");
combo._selectedText = "Davolio" + ";" + "Leverling";

Can someone guide me how can I set the text in DropDownTree
 Let me know in case of any more information

Vijay
David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 20 Sep 2019
2 answers
142 views

In my project, on one of the page, the HTML rendered by RadGrid contains three HTML tables (one for header, one for data, and one for footer).

But on another page, the HTML rendered contains only one HTML table.

I can't figure out what settings are affecting the different rendering layout. Please advise.

Thanks!

Sheng
Top achievements
Rank 1
Iron
Iron
 answered on 20 Sep 2019
1 answer
97 views

We are using Telerik grid filters to display configuration dashboard for release management status. I have few Columns i.e Application, environment, location. I want to retain columns parameters after I refresh the browser.

 

Is there way I can retain the parameters which are coming from the database?

-

Attila Antal
Telerik team
 answered on 20 Sep 2019
1 answer
374 views

Hi Team,

 

I have a got paging enabled on a Radgrid, and this grid is in a web user control, this grid usercontrol is also in another user control.

when I drop the user control on an ASPX page, it works fine. but when I put grid usercontrol in another usercontrol, initial it was doing a postback and refreshing the whole page, but I bypassed that by add a RadAjaxManagerProxy which handled the AjaxUpdatedControl.

But my issue now, is that once I click on a paging page, it shows the paging page, but it it stops clicking and can't navigate to the rest of the paging page.

Any help would be appreciated 

Thanks in Advance.

Attila Antal
Telerik team
 answered on 20 Sep 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?