Hi,
I have a RadGrid and whenever an "Add a new Record" or "Edit" button is pressed, i want to hide few databound details. I can able to hide textboxes when i press "Add a new record" but i can able to see Labels besides these textboxes.
How to hide labels beside these textboxes.
Moreover, during "Edit" button is pressed nothing is hiding, i can able to see labels and textboxes. Please tell me how to hide labels and textboxes during "Add a new record" or "Edit" button is pressed.
Thanks.
I have a RadGrid and whenever an "Add a new Record" or "Edit" button is pressed, i want to hide few databound details. I can able to hide textboxes when i press "Add a new record" but i can able to see Labels besides these textboxes.
How to hide labels beside these textboxes.
Moreover, during "Edit" button is pressed nothing is hiding, i can able to see labels and textboxes. Please tell me how to hide labels and textboxes during "Add a new record" or "Edit" button is pressed.
Thanks.
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 12 May 2009, 06:54 AM
Hi Syed,
To hide a column from appearing in the Edit mode as well as in the insert mode you may try setting its ReadOnly property to true.
ASPX:
Shinu
To hide a column from appearing in the Edit mode as well as in the insert mode you may try setting its ReadOnly property to true.
ASPX:
<telerik:GridBoundColumn HeaderText="ProductName" ReadOnly="true" DataField="ProductName" UniqueName="ProductName" ></telerik:GridBoundColumn> |
Shinu
0
Syed
Top achievements
Rank 1
answered on 12 May 2009, 07:17 AM
Hi,
I don't have GridBoundColumn. I am generating my data dynamically. But i can able to access textboxes .
The following code:
I don't have GridBoundColumn. I am generating my data dynamically. But i can able to access textboxes .
The following code:
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound |
If (TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted) Then |
Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) |
Dim txtbx1 As TextBox = DirectCast(insertItem("Resource_Name").Controls(0), TextBox) |
txtbx1.Text = RadComboBox1.SelectedValue.ToString |
Dim txtbx2 As TextBox = DirectCast(insertItem("Resource_Year").Controls(0), TextBox) |
txtbx2.Text = Year(Now).ToString |
Dim txtbx3 As TextBox = DirectCast(insertItem("Resource_Month").Controls(0), TextBox) |
txtbx3.Text = Month(Now).ToString |
Dim txtbx4 As TextBox = DirectCast(insertItem("Resource_week").Controls(0), TextBox) |
Dim txtbx5 As TextBox = DirectCast(insertItem("Division_ID").Controls(0), TextBox) |
Dim txtbx6 As TextBox = DirectCast(insertItem("Section_ID").Controls(0), TextBox) |
Dim txtbx7 As TextBox = DirectCast(insertItem("sno").Controls(0), TextBox) |
Dim mycal As New GregorianCalendar |
Dim weekNum As Double = (mycal.GetDayOfMonth(Now)) / 7 |
Dim s As Integer = 0 |
If weekNum <= 1 Then |
s = 1 |
ElseIf weekNum > 1 And weekNum <= 2 Then |
s = 2 |
ElseIf weekNum > 2 And weekNum <= 3 Then |
s = 3 |
ElseIf weekNum > 3 And weekNum <= 4 Then |
s = 4 |
ElseIf weekNum > 4 Then |
s = 5 |
End If |
txtbx4.Text = s.ToString() |
txtbx1.Visible = False |
txtbx2.Visible = False |
txtbx3.Visible = False |
txtbx4.Visible = False |
txtbx5.Visible = False |
txtbx6.Visible = False |
txtbx7.Visible = False |
End If |
End Sub |
0
Princy
Top achievements
Rank 2
answered on 12 May 2009, 10:03 AM
Hi Syed,
ReadOnly property is the best way to achieve you required scenario. If you are having autogeneratedcolumns try setting its ReadOnly property in the ColumnCreated event as shown below.
CS:
If this is not your requirement please feel free to ask more.
Regards
Princy.
ReadOnly property is the best way to achieve you required scenario. If you are having autogeneratedcolumns try setting its ReadOnly property in the ColumnCreated event as shown below.
CS:
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
{ |
foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) |
{ |
if (col.ColumnType == "GridBoundColumn") |
{ |
GridBoundColumn bndCol = (GridBoundColumn)col; |
bndCol.ReadOnly = true; |
} |
} |
} |
If this is not your requirement please feel free to ask more.
Regards
Princy.