12 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Mar 2013, 07:59 AM
Hi,
Since ReadOnly column will not be rendered in edit mode, a suggestion is to set the ReadOnly Column as the DataKeyName of the gridtableview and access the value as shown below.
aspx:
C#:
Thanks
Princy.
Since ReadOnly column will not be rendered in edit mode, a suggestion is to set the ReadOnly Column as the DataKeyName of the gridtableview and access the value as shown below.
aspx:
<
MasterTableView
DataKeyNames
=
"Id"
>
C#:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
string
value = editItem.GetDataKeyValue(
"Id"
).ToString();
}
Thanks
Princy.
0
Siva
Top achievements
Rank 1
answered on 19 Mar 2013, 10:38 AM
Thanks princy.. This code works fine :)
0
Tc Blaize
Top achievements
Rank 1
answered on 20 Mar 2013, 12:53 PM
Please how do i set value of just on cell in a radgrid each time a method is run.
NB: i want to achieve this in server-side.
NB: i want to achieve this in server-side.
0
Princy
Top achievements
Rank 2
answered on 21 Mar 2013, 06:24 AM
Hi,
Try the following code to achieve your scenario.
c#:
Thanks,
Princy
Try the following code to achieve your scenario.
c#:
public
void
change()
{
foreach
(GridDataItem dataItem
in
RadGrid1.Items)
{
dataItem[
"Uniquename"
].Text=
"text"
;
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
change();
}
Thanks,
Princy
0
James
Top achievements
Rank 1
answered on 14 Apr 2014, 03:13 PM
I am unable to retrieve the value of a cell when handling the UpdateCommand. I am not using automatic updates or column generation. I have read the docs and researched the forums to no avail. This is so basic I know I have to be doing something really stupid :) I have tried several different things including using EditMode of EditForms and InPlace. I either get empty strings returned or " ". See things I have attempted below. Any help appreciated.
Dim gei As GridEditableItem = TryCast(e.Item, GridEditableItem)
id = gei("Id").Text
Debug.Print("id: " & id)
txtBox = TryCast(gei("Id").Controls(0), TextBox)
If txtBox IsNot Nothing Then
Debug.Print("txtBox: " & txtBox.Text)
End If
txtBox2 = TryCast(gei.Controls(0).FindControl("Id"), TextBox)
If txtBox2 IsNot Nothing Then
Debug.Print("txtBox2: " & txtBox2.Text)
End If
tc = gei("id")
If tc IsNot Nothing Then
Debug.Print(tc.Text)
Else
Debug.Print("tc Is Nothing")
End If
gei.ExtractValues(di)
Debug.Print("di: " & di("Id").ToString)
Dim gei As GridEditableItem = TryCast(e.Item, GridEditableItem)
id = gei("Id").Text
Debug.Print("id: " & id)
txtBox = TryCast(gei("Id").Controls(0), TextBox)
If txtBox IsNot Nothing Then
Debug.Print("txtBox: " & txtBox.Text)
End If
txtBox2 = TryCast(gei.Controls(0).FindControl("Id"), TextBox)
If txtBox2 IsNot Nothing Then
Debug.Print("txtBox2: " & txtBox2.Text)
End If
tc = gei("id")
If tc IsNot Nothing Then
Debug.Print(tc.Text)
Else
Debug.Print("tc Is Nothing")
End If
gei.ExtractValues(di)
Debug.Print("di: " & di("Id").ToString)
0
Princy
Top achievements
Rank 2
answered on 16 Apr 2014, 05:30 AM
Hi James,
Please make sure you have not set the visibility of the column to false. Try the following code snippet to access the text in UpdateCommand.
ASPX:
VB:
If this doesn't help, please provide your aspx page as well.
Thanks,
Princy
Please make sure you have not set the visibility of the column to false. Try the following code snippet to access the text in UpdateCommand.
ASPX:
<
telerik:GridBoundColumn
UniqueName
=
"Id"
DataField
=
"Id"
HeaderText
=
"Id"
>
</
telerik:GridBoundColumn
>
VB:
Protected
Sub
RadGrid1_UpdateCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Dim
edit
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
txtId
As
TextBox =
DirectCast
(edit(
"Id"
).Controls(0), TextBox)
Dim
idValue
As
String
= txt.Text
End
Sub
If this doesn't help, please provide your aspx page as well.
Thanks,
Princy
0
James
Top achievements
Rank 1
answered on 16 Apr 2014, 09:16 PM
Hi Princy
Thanks very much for your quick reply. I have verified that the column ("Id") is visible. I also tested with your code snippet but continue to get an empty string when I check for the cell value. I have include the code you requested:
Protected Sub RadGrid1_UpdateCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
Dim edit As GridEditableItem = DirectCast(e.Item, GridEditableItem)
Dim txtId As TextBox = DirectCast(edit("Id").Controls(0), TextBox)
Dim idValue As String = txtId.Text
End Sub
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False">
<MasterTableView DataKeyNames="PriKey" EditMode="InPlace">
<RowIndicatorColumn Visible="False">
</RowIndicatorColumn>
<ExpandCollapseColumn Created="True">
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn HeaderText="Edit">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="PriKey"
FilterControlAltText="Filter PriKey column" HeaderText="PriKey" ReadOnly="True"
UniqueName="PriKey" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Id" FilterControlAltText="Filter Id column"
HeaderText="Id" UniqueName="Id">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Thanks again for your help.
Thanks very much for your quick reply. I have verified that the column ("Id") is visible. I also tested with your code snippet but continue to get an empty string when I check for the cell value. I have include the code you requested:
Protected Sub RadGrid1_UpdateCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
Dim edit As GridEditableItem = DirectCast(e.Item, GridEditableItem)
Dim txtId As TextBox = DirectCast(edit("Id").Controls(0), TextBox)
Dim idValue As String = txtId.Text
End Sub
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False">
<MasterTableView DataKeyNames="PriKey" EditMode="InPlace">
<RowIndicatorColumn Visible="False">
</RowIndicatorColumn>
<ExpandCollapseColumn Created="True">
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn HeaderText="Edit">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="PriKey"
FilterControlAltText="Filter PriKey column" HeaderText="PriKey" ReadOnly="True"
UniqueName="PriKey" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Id" FilterControlAltText="Filter Id column"
HeaderText="Id" UniqueName="Id">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Thanks again for your help.
0
Princy
Top achievements
Rank 2
answered on 17 Apr 2014, 03:42 AM
Hi James,
I'm not able to replicate the issue at my end. Below is a sample code snippet I tried which works as expected.
ASPX:
VB:
Thanks,
Princy
I'm not able to replicate the issue at my end. Below is a sample code snippet I tried which works as expected.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataSourceID
=
"SqlDataSource1"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridEditCommandColumn
HeaderText
=
"Edit"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
FilterControlAltText
=
"Filter OrderID column"
HeaderText
=
"OrderID"
ReadOnly
=
"True"
UniqueName
=
"OrderID"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"EmployeeID"
FilterControlAltText
=
"Filter EmployeeID column"
HeaderText
=
"EmployeeID"
UniqueName
=
"EmployeeID"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></
asp:SqlDataSource
>
VB:
Protected
Sub
RadGrid1_UpdateCommand(sender
As
Object
, e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
RadGrid1.UpdateCommand
Dim
edit
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
txtId
As
TextBox =
DirectCast
(edit(
"EmployeeID"
).Controls(0), TextBox)
Dim
idValue
As
String
= txtId.Text
'OR
Dim
newValues
As
New
Hashtable()
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, edit)
End
Sub
Thanks,
Princy
0
James
Top achievements
Rank 1
answered on 07 May 2014, 08:29 PM
Well, I tried your solution to no avail and I have experimented more hours than I care to admit with no success. One thing I found that will allow me to extract the values is if I specified something other than GridBoundColumn. If I use GridDateTimeColumn, GridNumericColumn or GridMaskedColumn I am able to extract the values but not if I use GridBoundColumn. I don't seem to have a choice but move back to using GridView and writing alot of code.
0
Princy
Top achievements
Rank 2
answered on 08 May 2014, 06:22 AM
Hi James,
Unfortunately, I'm unable to replicate this issue at my end.
Thanks,
Princy
Unfortunately, I'm unable to replicate this issue at my end.
Thanks,
Princy
0
James
Top achievements
Rank 1
answered on 05 Jun 2014, 05:21 PM
Hi
I developed a new form with a radgrid on it and was able to retrieve values from the cells. Without making any other changes I placed the radgrid on a contentpage that uses a masterpage and it stopped working. Are there any special tricks required when a master page is being used?
I developed a new form with a radgrid on it and was able to retrieve values from the cells. Without making any other changes I placed the radgrid on a contentpage that uses a masterpage and it stopped working. Are there any special tricks required when a master page is being used?
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2014, 04:36 AM
Hi James,
The provided information is not adequate to identify the issue. Please provide your code snippet. In case if you are Ajaxifying your Grid please note that in a complex scenario like WebUserControls or Master/ContentPages, we strongly recommend you to place RadAjaxManager instance on the main/master page and add a proxy control to the user control/content page as described in the following help topic:
RadAjax and MasterPage
Thanks,
Princy
The provided information is not adequate to identify the issue. Please provide your code snippet. In case if you are Ajaxifying your Grid please note that in a complex scenario like WebUserControls or Master/ContentPages, we strongly recommend you to place RadAjaxManager instance on the main/master page and add a proxy control to the user control/content page as described in the following help topic:
RadAjax and MasterPage
Thanks,
Princy