In the ItemDataBound event we are no longer to retrieve the Item value using the following code and are getting the value of ' '
If TypeOf e.Item Is GridDataItem Then Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) Dim EAFID As String = NoNull(dataItem("row_ID").toString)This seems to be after a recent update of telerik versions as we were getting valid values.
Any help or clues on why this method of access is not working?
6 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 May 2013, 03:52 AM
Hello,
1. boundcolumn
2.datakey
3. lable in template column
Thanks,
Jayesh Goyani
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = TryCast(e.Item, GridDataItem) Dim strrow_ID As String = item("row_ID").Text ' for bound column Dim keyrow_ID As String = item.GetDataKeyValue("row_ID").ToString() ' using key value Dim Labelrow_ID As String = TryCast(item.FindControl("Label1"), Label).Text ' Get label from ItemTemplate
End IfEnd Sub1. boundcolumn
<telerik:GridBoundColumn DataField="row_ID" UniqueName="row_ID" HeaderText="row_ID"> </telerik:GridBoundColumn>2.datakey
<MasterTableView DataKeyNames="row_ID">3. lable in template column
<telerik:GridTemplateColumn> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("row_ID") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn>Thanks,
Jayesh Goyani
0
TadR
Top achievements
Rank 1
answered on 14 May 2013, 05:34 PM
Hello Jayesh:
Thank you for your response.
However, I can't figure out how your response code is different than my original post. Am I missing something?
If we use:
Thank you for your response.
However, I can't figure out how your response code is different than my original post. Am I missing something?
If we use:
Dim EAFID As String = NoNull(dataItem("row_ID").Text) gives us back a non breaking space as value
Dim EAFID As String = NoNull(e.Item.DataItem("row_ID")) gives us back the correct value.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 May 2013, 06:52 PM
Hello,
I have shown three different way to get datafield in ItemDataBound event.
if this code is not worked for you then please provide your code.
Thanks,
Jayesh Goyani
I have shown three different way to get datafield in ItemDataBound event.
if this code is not worked for you then please provide your code.
Thanks,
Jayesh Goyani
0
Accepted
Vijay
Top achievements
Rank 1
answered on 14 May 2013, 07:09 PM
TadR,
I ran into a similar problem after upgrading to the Q1 2013 AJAX controls, but for me I only had issues accessing the data for columns that were set to visible="false". Not sure if the same is true in your case. I found this thread about a breaking change and was able to resolve my issue by using display="false" instead of using the visible="false".
http://www.telerik.com/community/forums/aspnet-ajax/grid/breaking-change-hidden-column-cell-text-is-not-persisted-in-viewstate.aspx
Hope this helps,
Vijay
I ran into a similar problem after upgrading to the Q1 2013 AJAX controls, but for me I only had issues accessing the data for columns that were set to visible="false". Not sure if the same is true in your case. I found this thread about a breaking change and was able to resolve my issue by using display="false" instead of using the visible="false".
http://www.telerik.com/community/forums/aspnet-ajax/grid/breaking-change-hidden-column-cell-text-is-not-persisted-in-viewstate.aspx
Hope this helps,
Vijay
0
Phil
Top achievements
Rank 1
answered on 12 Jul 2013, 04:10 PM
Another option if processing RadGrid_ColumnCreated is to set the set the .Visible=true and .Display=false.
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) { if (e.Column.UniqueName == "ROWNO") { e.Column.HeaderText = "row no"; //probably not necessary used for debugging e.Column.Visible = true; //setting false results in null value e.Column.Display = false; //set true to see values }}0
Josef Rogovsky
Top achievements
Rank 2
answered on 13 Sep 2016, 12:38 AM
Vijay, you just saved me a lot of frustration. Thank you!