
I have a dropdownlist in my EditFormTemplate. In the code for OnItemCreated I have the following:
If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
'create oDataTable
Dim ddl As DropDownList = TryCast(e.Item.FindControl("ddOfficeID"), DropDownList)
ddl.DataSource = oDataTable
ddl.DataTextField = "OfficeName"
ddl.DataValueField = "OfficeID"
ddl.DataBind()
End If
In the code for OnUpdateCommand I have the following:
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim PersonnelID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("PersonnelID").ToString()
'get other values...
Dim OfficeID As String = (TryCast(editedItem.FindControl("ddOfficeID"), DropDownList)).Text
strSQL = "UPDATE tPersonnel SET [OtherValues] = '" & OtherValues& "', [OfficeID] = " & OfficeID & " WHERE ([PersonnelID] = " & PersonnelID & ")"
'update database...
So far my dropdownlist is bound when the grid goes into edit mode and the database is updated when the Update button is clicked.
My only problem is that when the edit form is loaded the dropdownlist does not reflect the original selected value. When I tried adding SelectedValue='<%# Eval("OfficeID")%>' to my dropdownlist, it generates the following error:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Since the dropdown is being bound on ItemCreated, I'm confused by that error. I've seen some other threads about this, but frankly they were over my head. Can someone explain in super simple terms how to set the selectedvalue?
Thanks!
| If (TypeOf (e.Item) Is GridDataItem) Then |
| 'Get the instance of the right type |
| Dim dataBoundItem As GridDataItem = e.Item |
| 'Check the formatting condition |
| If (dataBoundItem("wydarzenie_id").Text).Length > 6 Then |
| dataBoundItem("wydarzenie_id").Text = "asd" |
| 'Customize more... |
| End If |
| End If |
<
telerik:RadGrid...
AutoGenerateEditColumn="True"
AutoGenerateDeleteColumn="True"
<
MasterTableView...
AutoGenerateColumns="True"
That means i do not have any columns in aspx because i bind the grid to the datasource in "DropDownList1_SelectedIndexChanged" event.
How to:
1- Change "Edit,Delete" column index?
ex: Make Delete column the last one.
2- Convert "Edit,Delete" column "ButtonType" to "ImageButton"?
| .txt_box { |
| padding: 3px 5px; |
| border: 1px solid #CCCCCC; |
| background: url(../images/homepage19.gif) repeat-x left top; |
| } |
| <EnabledStyle CssClass="txt_box" PaddingLeft="4px" /> |
protected void OnItemDataBoundGrid(object sender, Telerik.Web.UI.GridItemEventArgs e)
for the rad grid
So I need something like
protected void OnItemDataBoundGrid(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
GridTemplateColumn gtc = (GridTemplateColumn)item["gtc1"].FindControl("idontknow");
}
}
I need to change the text in the header.
I originall had the text here
<telerik:GridTemplateColumn HeaderText="CLICK HERE TO SORT" SortExpression="CostToDate" UniqueName="gtc2">
<HeaderTemplate>
<asp:LinkButton ID="lblCostYear" CommandName="Sort" runat="server" OnDataBinding="OnBindCostYearHeader"></asp:LinkButton>
</HeaderTemplate>
But if I put the text in the linkbutton the automatic sorting doesnt take effect
help
Imports
Telerik.Web.UI
| Protected Sub RadScheduler1_AppointmentCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentCreatedEventArgs) Handles RadScheduler1.AppointmentCreated |
| If (e.Appointment.Visible _ |
| AndAlso Not IsAppointmentRegisteredForTooltip(e.Appointment)) Then |
| RadToolTipManager1.TargetControls.Add(e.Appointment.ClientID, True) |
| End If |
| End Sub |