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.
}
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
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);
}
<
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.
<
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
>
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(x);
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!
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?
-
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.