I have designed my radgrid with gridtemplatecolumns as follows .. Sample one
I would like to find this textbox with out adding the FirstName to Datakey in RadGrid_UpdateCommand can some one help me
<
telerik:GridTemplateColumn
DataField
=
"FirstName"
AllowFiltering
=
"true"
HeaderText
=
"First Name"
UniqueName
=
"FirstName"
>
<
ItemTemplate
>
<%# Eval("FirstName")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"rdtxtFrstName"
runat
=
"server"
Text='<%# Eval("FirstName") %>'
Width="150px" />
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
I would like to find this textbox with out adding the FirstName to Datakey in RadGrid_UpdateCommand can some one help me
8 Answers, 1 is accepted
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jul 2012, 04:45 PM
Hello,
Thanks,
Jayesh Goyani
protected
void
dgPassanger_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadTextBox rdtxtFrstName = item.FindControl(
"rdtxtFrstName"
)
as
RadTextBox;
// Access your TextBox here
}
Thanks,
Jayesh Goyani
0
Dorababu
Top achievements
Rank 1
answered on 05 Jul 2012, 08:41 AM
Thanks Jayesh Goyani I need a small favour I would like to get the text from GridTemplatecolumn in ItemDataBund and set the selected value to dropdown
this is my sample
I need to find out the text and when binding the drop down I would like to set the selected text to that text
this is my sample
<
telerik:GridTemplateColumn
DataField
=
"MaritalTypeID"
AllowFiltering
=
"true"
HeaderText
=
"MaritalTypeID"
UniqueName
=
"MaritalTypeID"
>
<
ItemTemplate
>
<%# Eval("MaritalTypeID")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"rdcbGender"
AutoPostBack
=
"false"
runat
=
"server"
Width
=
"200px"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
I need to find out the text and when binding the drop down I would like to set the selected text to that text
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
mlocal_strStoredProcName = StoredProcNames.Gender_uspGenderGetList;
oEmployeePersonalData.Select(
out
mlocal_ds, mlocal_strStoredProcName);
if
(!e.Item.OwnerTableView.IsItemInserted)
{
RadComboBox rdcmbGender = (RadComboBox)item.FindControl(
"rdcbGender"
);
rdcmbGender.DataSource = mlocal_ds;
rdcmbGender.DataTextField = TablesAndColumns.tblGender_GenderDesc;
rdcmbGender.DataValueField = TablesAndColumns.tblGender_GenderTypeID;
rdcmbGender.DataBind();
}
}
}
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Jul 2012, 09:13 AM
Hi,
Please try the following code snippet to give the SelectedValue in the RadComboBox.
C#:
Hope this helps.
Thanks,
Princy.
Please try the following code snippet to give the SelectedValue in the RadComboBox.
C#:
if
(!e.Item.OwnerTableView.IsItemInserted)
{
RadComboBox rdcmbGender = (RadComboBox)item.FindControl(
"rdcbGender"
);
rdcmbGender.DataSource = mlocal_ds;
rdcmbGender.DataTextField = TablesAndColumns.tblGender_GenderDesc;
rdcmbGender.DataValueField = TablesAndColumns.tblGender_GenderTypeID;
rdcmbGender.SelectedValue=(
string
)DataBinder.Eval(e.Item.DataItem,
"MaritalTypeID"
).ToString();
// setting "MaritalTypeID" as selected value
rdcmbGender.DataBind();
}
Hope this helps.
Thanks,
Princy.
0
Dorababu
Top achievements
Rank 1
answered on 05 Jul 2012, 09:43 AM
Perfect thanks both of you
0
João
Top achievements
Rank 1
answered on 28 Apr 2014, 02:30 PM
Hi, I have designed the following radgrid for using BatchEdit:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SQLDSIndicadores" AutoGenerateColumns="False" GridLines="none" Culture="pt-PT" AllowAutomaticUpdates="True">
<MasterTableView DataSourceID="SQLDSIndicadores" DataKeyNames="IDII" EditMode="Batch" CommandItemDisplay="Top">
<BatchEditingSettings EditType="Cell" OpenEditingEvent="DblClick" />
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="Grupo" HeaderText=" " HeaderValueSeparator=""/>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Grupo"/>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<CommandItemSettings ShowSaveChangesButton="true" ShowRefreshButton="False" ShowAddNewRecordButton="False" SaveChangesText="Guardar Alterações" />
<Columns>
<telerik:GridBoundColumn DataField="IDII" HeaderText="IDII" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDGrupo" HeaderText="IDGrupo" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Grupo" HeaderText="Grupo" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDGrupoPai" HeaderText="IDGrupoPai" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDIndicador" HeaderText="ID Indicador" Display="False" HeaderStyle-Width="80%"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Indicador" HeaderText="Indicador" ReadOnly="True"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="TipoValor" HeaderText="TipoValor" Display="False" UniqueName="TipoValor"></telerik:GridBoundColumn>
<%--<telerik:GridBoundColumn DataField="Valor" HeaderText="Valor" UniqueName="Valor" HeaderStyle-Width="20%"></telerik:GridBoundColumn>--%>
<telerik:GridTemplateColumn DataField="Valor" HeaderText="Valor" UniqueName="Valor" HeaderStyle-Width="20%">
<ItemTemplate>
<asp:Label runat="server" ID="Valor" Text='<%# Bind("Valor")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="boolValor" runat="server" Visible="False" />
<telerik:RadTextBox ID="strValor" runat="server" Visible="False"></telerik:RadTextBox>
<telerik:RadNumericTextBox runat="server" ID="intValor" Visible="False"></telerik:RadNumericTextBox>
<telerik:RadNumericTextBox runat="server" ID="floatValor" Visible="False"></telerik:RadNumericTextBox>
<telerik:RadDatePicker ID="dateValor" runat="server" Visible="False"></telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
What I need to do, is when I double click a cell, I want to change the visibility of EditItemTemplate controls based on the value of the column "TipoValor" and Bound the Datafield "Valor" to it. How can I do this?
Best regards,
João
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SQLDSIndicadores" AutoGenerateColumns="False" GridLines="none" Culture="pt-PT" AllowAutomaticUpdates="True">
<MasterTableView DataSourceID="SQLDSIndicadores" DataKeyNames="IDII" EditMode="Batch" CommandItemDisplay="Top">
<BatchEditingSettings EditType="Cell" OpenEditingEvent="DblClick" />
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldName="Grupo" HeaderText=" " HeaderValueSeparator=""/>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Grupo"/>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<CommandItemSettings ShowSaveChangesButton="true" ShowRefreshButton="False" ShowAddNewRecordButton="False" SaveChangesText="Guardar Alterações" />
<Columns>
<telerik:GridBoundColumn DataField="IDII" HeaderText="IDII" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDGrupo" HeaderText="IDGrupo" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Grupo" HeaderText="Grupo" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDGrupoPai" HeaderText="IDGrupoPai" Display="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="IDIndicador" HeaderText="ID Indicador" Display="False" HeaderStyle-Width="80%"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Indicador" HeaderText="Indicador" ReadOnly="True"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="TipoValor" HeaderText="TipoValor" Display="False" UniqueName="TipoValor"></telerik:GridBoundColumn>
<%--<telerik:GridBoundColumn DataField="Valor" HeaderText="Valor" UniqueName="Valor" HeaderStyle-Width="20%"></telerik:GridBoundColumn>--%>
<telerik:GridTemplateColumn DataField="Valor" HeaderText="Valor" UniqueName="Valor" HeaderStyle-Width="20%">
<ItemTemplate>
<asp:Label runat="server" ID="Valor" Text='<%# Bind("Valor")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="boolValor" runat="server" Visible="False" />
<telerik:RadTextBox ID="strValor" runat="server" Visible="False"></telerik:RadTextBox>
<telerik:RadNumericTextBox runat="server" ID="intValor" Visible="False"></telerik:RadNumericTextBox>
<telerik:RadNumericTextBox runat="server" ID="floatValor" Visible="False"></telerik:RadNumericTextBox>
<telerik:RadDatePicker ID="dateValor" runat="server" Visible="False"></telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
What I need to do, is when I double click a cell, I want to change the visibility of EditItemTemplate controls based on the value of the column "TipoValor" and Bound the Datafield "Valor" to it. How can I do this?
Best regards,
João
0
Hello João,
You can use the OnBatchEditOpened client-side handler provided by RadGrid:
http://www.telerik.com/help/aspnet-ajax/grid-onbatcheditopened.html
And use some script logic to find the required elements:
Hope this helps.
Regards,
Eyup
Telerik
You can use the OnBatchEditOpened client-side handler provided by RadGrid:
http://www.telerik.com/help/aspnet-ajax/grid-onbatcheditopened.html
And use some script logic to find the required elements:
var
container =
item
.get_element();
// finding RadControl:
var
control = $telerik.findControl(container,
"ControlID"
);
// finding element:
var
element = $telerik.findElement(container,
"ElementID"
);
Hope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Jawwad
Top achievements
Rank 1
answered on 24 Dec 2014, 12:46 PM
Hello Eyup,
Regarding your code block in last post, from where the item is coming ? How you are setting this variable? I am unable to get the container from here.
Also my requirement is getting the textbox in my item template. For that I guess this is the right suggestion if I get the container element.
Regarding your code block in last post, from where the item is coming ? How you are setting this variable? I am unable to get the container from here.
Also my requirement is getting the textbox in my item template. For that I guess this is the right suggestion if I get the container element.
0
Hi Jawwad,
The item(row) is passed from event arguments:
http://www.telerik.com/help/aspnet-ajax/grid-onbatcheditopened.html
Hope this helps.
Regards,
Eyup
Telerik
The item(row) is passed from event arguments:
http://www.telerik.com/help/aspnet-ajax/grid-onbatcheditopened.html
Hope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.