Hi
I load the grid and GridDropDownColumn column from code behind, everty thing works fine except the first row doesn't show the value
thanks
small sample which I found from Forum
code behind
I load the grid and GridDropDownColumn column from code behind, everty thing works fine except the first row doesn't show the value
thanks
small sample which I found from Forum
<div> <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true" AutoGenerateEditColumn="true" > <MasterTableView EditMode="InPlace"> <Columns> <telerik:GridBoundColumn DataField="Col1"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="Col2" ListTextField="value" ListValueField="index" UniqueName="DropDownColumn"> </telerik:GridDropDownColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div>code behind
Imports Telerik.Web.UIPublic Class WebForm6 Inherits System.Web.UI.Page Private _isBound As Boolean = False Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Private Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated If TypeOf e.Item Is GridDataItem Then If Not _isBound Then DirectCast(DirectCast(RadGrid1.MasterTableView.GetColumnSafe("DropDownColumn"), GridDropDownColumn).ColumnEditor, GridDropDownColumnEditor).DataSource = GetDropDownData() _isBound = True End If End If End Sub Private Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = GetGridData() End Sub Private Function GetDropDownData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("index") dataTable.Columns.Add("value") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTable End Function Private Function GetGridData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("Col1") dataTable.Columns.Add("Col2") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTable End FunctionEnd Class8 Answers, 1 is accepted
0
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Jun 2013, 09:11 AM
Hello,
Please try with below code snippet.
Thanks,
Jayesh Goyani
Please try with below code snippet.
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"> <MasterTableView EditMode="InPlace" DataKeyNames="Col2"> <Columns> <telerik:GridBoundColumn DataField="Col1"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="Col2" ListTextField="value" ListValueField="index" UniqueName="DropDownColumn"> </telerik:GridDropDownColumn> <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> </Columns> </MasterTableView> </telerik:RadGrid>Protected Sub Page_Load(sender As Object, e As System.EventArgs)End SubProtected Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)End SubProtected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) RadGrid1.DataSource = GetGridData()End SubPrivate Function GetDropDownData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("index") dataTable.Columns.Add("value") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTableEnd FunctionPrivate Function GetGridData() As DataTable Dim dataTable As New DataTable() dataTable.Columns.Add("Col1") dataTable.Columns.Add("Col2") For i As Integer = 0 To 19 dataTable.Rows.Add(New Object() {i, i}) Next Return dataTableEnd FunctionProtected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) If (dataItem("DropDownColumn").Controls(0)).[GetType]() = GetType(System.Web.UI.WebControls.Literal) Then DirectCast(dataItem("DropDownColumn").Controls(0), Literal).Text = dataItem.GetDataKeyValue("Col2").ToString() End If End If If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then Dim dataItem As GridEditableItem = DirectCast(e.Item, GridEditableItem) DirectCast(DirectCast(RadGrid1.MasterTableView.GetColumnSafe("DropDownColumn"), GridDropDownColumn).ColumnEditor, GridDropDownColumnEditor).DataSource = GetDropDownData() DirectCast(DirectCast(RadGrid1.MasterTableView.GetColumnSafe("DropDownColumn"), GridDropDownColumn).ColumnEditor, GridDropDownColumnEditor).DataBind() DirectCast(DirectCast(RadGrid1.MasterTableView.GetColumnSafe("DropDownColumn"), GridDropDownColumn).ColumnEditor, GridDropDownColumnEditor).SelectedValue = dataItem.GetDataKeyValue("Col2").ToString() End IfEnd Sub'======================================================='Service provided by Telerik (www.telerik.com)'Conversion powered by NRefactory.'Twitter: @telerik, @toddanglin'Facebook: facebook.com/telerik'=======================================================Thanks,
Jayesh Goyani
0
ShahabG
Top achievements
Rank 1
answered on 21 Jun 2013, 01:48 PM
Thanks Jayesh,
It worked fine, But when I change the EditMode="Batch" ,The
It worked fine, But when I change the EditMode="Batch" ,The
ItemDataBound event will not trigger, Do you know how to solve this issue?
Thanks0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Jun 2013, 10:38 AM
Hello,
Add Item in RadComboBox on Clinet side
Batch Editing : Access control and get/set value in it
Thanks,
Jayesh Goyani
<ClientSettings> <ClientEvents OnBatchEditSetEditorValue="GetEditorValue" /> </ClientSettings><script type="text/javascript"> function GetEditorValue(sender, args) { if (args.get_columnUniqueName() === "DropDownColumn") { var combobox = $telerik.findControl(args.get_container(), "DropDownColumn"); // Please access combobox here (and add item here). } } </script>Add Item in RadComboBox on Clinet side
Batch Editing : Access control and get/set value in it
Thanks,
Jayesh Goyani
0
ShahabG
Top achievements
Rank 1
answered on 24 Jun 2013, 11:34 AM
Thanks,
Is there a Server side event which I can use instead of client side?
thanks
Is there a Server side event which I can use instead of client side?
thanks
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Jun 2013, 01:23 PM
Hello,
As per my knowledge there is not any server side event is there.
Thanks,
Jayesh Goyani
As per my knowledge there is not any server side event is there.
Thanks,
Jayesh Goyani
0
ShahabG
Top achievements
Rank 1
answered on 28 Jun 2013, 12:10 PM
Hi Jayesh
I have 4 grids on batch mode on a page, I have to updated all of them in once with a Save button, How do I get only the records which are changed in each grid?
Thanks
I have 4 grids on batch mode on a page, I have to updated all of them in once with a Save button, How do I get only the records which are changed in each grid?
Thanks
0
Hi Shahab,
I have already provided an answer to this question in the other forum ticket which you have opened regarding this matter. In order to avoid duplicate posts I suggest that we continue our communication there.
Regards,
Angel Petrov
Telerik
I have already provided an answer to this question in the other forum ticket which you have opened regarding this matter. In order to avoid duplicate posts I suggest that we continue our communication there.
Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.