
Web Services
Top achievements
Rank 2
Web Services
asked on 15 Aug 2011, 04:28 PM
I'm looking for just a concept idea on this. I have a grid view and I would like one field to show data. Then, when you click on it, it changes to a text box that is editable and a user can edit that field and save it. Any thoughts on how to do this? I also thought about showing a tool tip on click with a text box and save button. Which do you think is better/easier?
9 Answers, 1 is accepted
0
Accepted

Elliott
Top achievements
Rank 2
answered on 15 Aug 2011, 08:06 PM
I'm doing this in an app
<
telerik:GridTemplateColumn
UniqueName
=
"Qty"
HeaderText
=
"Cases"
DataField
=
"Qty"
DataType
=
"System.Int32"
Aggregate
=
"Sum"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQty"
Text='<%# Bind("Qty") %>' Width="40px" runat="server" />
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntbQty"
Value='<%# Eval("Qty") %>' OnTextChanged="rntbQty_TextChanged" AutoPostBack="True" Width="40px" runat="server">
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"40px"
/>
</
telerik:GridTemplateColumn
>
....
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick" />
<ClientEvents OnRowClick="RowClick" />
protected
void
rntbQty_TextChanged(
object
sender, EventArgs e)
{
RadNumericTextBox rntbQty;
GridDataItem gdItem;
GridEditableItem geItem;
DateTime ShipDate;
int
Qty,iBooth,iPage,iConsolid;
double
fStore,dVendor,dItemID,dNetCost;
string
[] strDel =
new
string
[1];
double
[] dQty =
new
double
[1];
Hashtable CornedBeef;
WsOrderSystem wsOrder;
bool
bUpdate =
false
;
rntbQty = (RadNumericTextBox)sender;
gdItem = rntbQty.NamingContainer
as
GridDataItem;
geItem = rntbQty.NamingContainer
as
GridEditableItem;
CornedBeef =
new
Hashtable();
gdItem.ExtractValues(CornedBeef);
ShipDate = Convert.ToDateTime(CornedBeef[
"ShipDate"
]);
Qty = Convert.ToInt32(rntbQty.Value);
fStore = Convert.ToDouble(ExtractValue(geItem,
"StoreNumber"
));
iBooth = Convert.ToInt32(ExtractValue(geItem,
"BoothNumber"
));
iPage = Convert.ToInt32(ExtractValue(geItem,
"PageNumber"
));
dVendor = Convert.ToDouble(ExtractValue(geItem,
"VendorNumber"
));
dNetCost = Convert.ToDouble(ExtractValue(geItem,
"NetCost"
));
dItemID = Convert.ToDouble(ExtractValue(geItem,
"ItemID"
));
iConsolid = Convert.ToInt32(txtConsolid.Value);
strDel[0] = ShipDate.ToShortDateString();
dQty[0] = Qty;
wsOrder =
new
WsOrderSystem();
bUpdate = wsOrder.AddToOrder(fStore,iBooth,iPage,dVendor,dNetCost,dItemID,strDel,dQty,
true
,iConsolid);
}
</ClientSettings>
</telerik:RadGrid>
<telerik:RadCodeBlock ID=
"rcBlock"
runat=
"server"
>
<script type=
"text/javascript"
>
<!--
function
RowDblClick(sender, eventArgs) {
idx = eventArgs.get_itemIndexHierarchical();
sender.get_masterTableView().editItem(idx);
}
function
RowClick(sender, eventArgs) {
idx = eventArgs.get_itemIndexHierarchical();
sender.get_masterTableView().editItem(idx);
}
-->
</script>
</telerik:RadCodeBlock>
0

Web Services
Top achievements
Rank 2
answered on 15 Aug 2011, 10:04 PM
I'm running into an issue with the text box. My visual basic is saying it can't find the text box. Here is my aspx
And here is my code behind
I'm getting an error saying 'goalHoursInput' is not declared. It may be inaccessible due to its protection level.
<
telerik:GridTemplateColumn
DataField
=
"goalhours"
HeaderText
=
"Goal"
SortExpression
=
"goalHours"
UniqueName
=
"goalHours"
HeaderStyle-Width
=
"80px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"goalOutput"
runat
=
"server"
Text='<%# Bind("goalHours") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"goalHoursInput"
Runat
=
"server"
Value='<%# Eval("goalHours") %>' AutoPostBack="true" Width="40px">
<
NumberFormat
DecimalDigits
=
"2"
/>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
And here is my code behind
Protected
Sub
goalHoursInput_TextChanged(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Dim
textBox
As
RadNumericTextBox = goalHoursInput
Dim
gridItem
As
GridDataItem
End
Sub
'end sub
0

Elliott
Top achievements
Rank 2
answered on 15 Aug 2011, 10:09 PM
the sender is the textbox
put that in your TextChanged event
Dim
rntbQty as RADNumericTextBox
rntbQty =
DirectCast
(sender,RadNumericTextBox)
put that in your TextChanged event
0

Web Services
Top achievements
Rank 2
answered on 15 Aug 2011, 10:23 PM
I see, thanks. I'm getting an issue when you click the text box, I see it does the post back but I get a cast issue. I should mention that I populate this grid with a custom data table that I built on the back end. However, I'm pretty sure I'm populating that field with a double. Here's the error.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
|
0

Princy
Top achievements
Rank 2
answered on 16 Aug 2011, 06:42 AM
Hello,
Try the following code snippet to achieve the scenario.
VB:
Thanks,
Princy.
Try the following code snippet to achieve the scenario.
VB:
Protected
Sub
txt_TextChanged(sender
As
Object
, e
As
EventArgs)
Dim
txt
As
RadNumericTextBox = TryCast(sender, RadNumericTextBox)
Dim
item
As
GridEditableItem =
DirectCast
(txt.NamingContainer, GridEditableItem)
End
Sub
Thanks,
Princy.
0

Web Services
Top achievements
Rank 2
answered on 16 Aug 2011, 10:58 PM
I changed the radnumeric to just a rad textbox and it worked. However, that's not exactly what I was looking for. I want to just change that one column to a text box within the actual line. I don't need everything to be editable, just that one field. Any ideas?
0
Accepted

Elliott
Top achievements
Rank 2
answered on 17 Aug 2011, 02:09 PM
set every other column in yoyur RADGrid to ReadOnly="True"
0

Web Services
Top achievements
Rank 2
answered on 17 Aug 2011, 03:05 PM
You are awesome, thanks.
0

Paul
Top achievements
Rank 1
answered on 22 Jan 2014, 03:19 PM
Just Change Value to text Mean from
TO
Value='<%# Eval("goalHours") %>' AutoPostBack="true" Width="40px">
TO
Text='<%# Eval("goalHours") %>' AutoPostBack="true" Width="40px">