Hi everyone,
I have been banging my head against the wall today trying to find a solution to my problem so any help is much appreciated.
I have a radGrid that I have bound to a datatable server side and this datatable contains a column(img) of type "Image" in the back end (SQL Server 2005). I have AutoGenerateColumns set to True as the application we are building is an interrogation tool to any database or table on our server, I therefore cannot add all of the columns manually. Now, when the grid is displayed, the column "img" is not shown at all.
My first question is why this is the case and is there a setting that can be changed in order for the grid to automatically display these columns? Even if there is, we have another requirement which I am unsure how to solve?
So, firstly we need the column adding to the grid, then if the DataRow has binary data in it we would like to display the word "BLOB" in the radGrid cell. If the row does not have any data then the word "blob" in lower case should be displayed. Lastly, we then need to add a click event to that cell that will fire up a new radWindow where we can display the binary data in a text field or binary editor. (Potentially even show the image and allow them to change it?).
I have attached the code for completeness sake,
Look forward to hearing your responses.
Thanks,
M
And the code behind:
I have been banging my head against the wall today trying to find a solution to my problem so any help is much appreciated.
I have a radGrid that I have bound to a datatable server side and this datatable contains a column(img) of type "Image" in the back end (SQL Server 2005). I have AutoGenerateColumns set to True as the application we are building is an interrogation tool to any database or table on our server, I therefore cannot add all of the columns manually. Now, when the grid is displayed, the column "img" is not shown at all.
My first question is why this is the case and is there a setting that can be changed in order for the grid to automatically display these columns? Even if there is, we have another requirement which I am unsure how to solve?
So, firstly we need the column adding to the grid, then if the DataRow has binary data in it we would like to display the word "BLOB" in the radGrid cell. If the row does not have any data then the word "blob" in lower case should be displayed. Lastly, we then need to add a click event to that cell that will fire up a new radWindow where we can display the binary data in a text field or binary editor. (Potentially even show the image and allow them to change it?).
I have attached the code for completeness sake,
Look forward to hearing your responses.
Thanks,
M
<
telerik:RadGrid
ID
=
"gdData"
runat
=
"server"
AllowSorting
=
"True"
AllowPaging
=
"True"
AllowCustomPaging
=
"True"
Height
=
"550px"
PageSize
=
"30"
GridLines
=
"None"
PagerStyle-Visible
=
"false"
OnNeedDataSource
=
"gdData_NeedDataSource"
AllowFilteringByColumn
=
"True"
AutoGenerateEditColumn
=
"True"
Skin
=
"WebBlue"
>
<
MasterTableView
TableLayout
=
"Auto"
CommandItemDisplay
=
"None"
CurrentResetPageIndexAction
=
"SetPageIndexToFirst"
PageSize
=
"30"
EditMode
=
"InPlace"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
/>
<
ItemStyle
Wrap
=
"False"
/>
<
AlternatingItemStyle
Wrap
=
"False"
/>
</
MasterTableView
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
Scrolling-SaveScrollPosition
=
"true"
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
ScrollHeight
=
"100px"
EnableVirtualScrollPaging
=
"true"
/>
<
ClientEvents
OnRowCreated
=
"AddTooltips"
/>
<
Resizing
AllowColumnResize
=
"True"
EnableRealTimeResize
=
"False"
/>
</
ClientSettings
>
<
PagerStyle
Visible
=
"False"
/>
</
telerik:RadGrid
>
And the code behind:
protected
void
gdData_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if
(GetData)
{
// Find out how many records have already been shown so we can work out start position
int
startPos = gdData.CurrentPageIndex * gdData.PageSize;
this
.GridData = DataAccess.GetData(CurrentConStr, cbTable.SelectedValue, startPos, gdData.PageSize);
gdData.VirtualItemCount =
this
.GridData.recordcount;
gdData.DataSource =
this
.GridData.Ds.Tables[0];
}
}