Hello,
I am very new to .NET and the telerik UI (5 days of experience) and I am working with radgrid. I know many people have posted questions about this before, but I still can't seem to figure it out. I have a grid that gets its original data from a database. I want to be able to edit each cell individually and update the data to the database. I have been trying for hours but I can't get any of the cells to edit or even get any handlers to fire. Thank you in advance.
ASP.NET code:
C# code:
Please Note: This is the code that generates the grid using the data from the database. I need to modify this code to make the grid editable. Thank you
I am very new to .NET and the telerik UI (5 days of experience) and I am working with radgrid. I know many people have posted questions about this before, but I still can't seem to figure it out. I have a grid that gets its original data from a database. I want to be able to edit each cell individually and update the data to the database. I have been trying for hours but I can't get any of the cells to edit or even get any handlers to fire. Thank you in advance.
ASP.NET code:
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
div
>
<
telerik:RadGrid
ID
=
"GrdConfig"
runat
=
"server"
CellSpacing
=
"0"
GridLines
=
"None"
EnableLinqExpressions
=
"False"
oncolumncreated
=
"GrdConfig_ColumnCreated"
CssClass
=
"MyRadGridCssClass"
AllowPaging
=
"True"
>
<
ClientSettings
>
<
Resizing
AllowColumnResize
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
C# code:
public
partial
class
Configurations : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
** Code to extract data from database goes here**
GrdConfig.DataSource = data;
GrdConfig.DataBind();
GridGroupByExpression expression = GridGroupByExpression.Parse(
"ConfigFile[Config File:] Group by ConfigFile"
);
GrdConfig.MasterTableView.GroupByExpressions.Add(expression);
GridColumn cConfig = GrdConfig.MasterTableView.GetColumnSafe(
"ConfigFile"
);
cConfig.Visible =
false
;
GrdConfig.Rebind();
}
protected
void
GrdConfig_ColumnCreated(
object
sender, GridColumnCreatedEventArgs e)
{
if
(e.Column
is
GridGroupSplitterColumn)
{
e.Column.HeaderStyle.Width = Unit.Pixel(1);
e.Column.HeaderStyle.Font.Size = FontUnit.Point(1);
e.Column.ItemStyle.Width = Unit.Pixel(1);
e.Column.ItemStyle.Font.Size = FontUnit.Point(1);
e.Column.Resizable =
false
;
}
}
protected
void
GrdConfig_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridGroupHeaderItem)
{
GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)e.Item;
groupHeader.Font.Bold =
true
;
}
}
}
}
Please Note: This is the code that generates the grid using the data from the database. I need to modify this code to make the grid editable. Thank you