
Milan Gurung
Top achievements
Rank 1
Milan Gurung
asked on 07 Jan 2009, 11:17 AM
Hi,
I have a radGrid as below (partial code):
<Columns>
<telerik:GridTemplateColumn DataField="InvoiceDetailID" HeaderText="InvoiceDetailID" UniqueName="InvoiceDetailID" Display="false">
<ItemTemplate>
<asp:Label ID="lblInvoiceDetailID" runat="server" Text='<%# Bind("InvoiceDetailID") %>' >' </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtInvoiceDetailID" Text='<%# Bind("InvoiceDetailID") %>' runat="server" ReadOnly="true"></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Coloumns>
My problem is when the Grid is in Edit or Insert mode, InvoiceDetailID field is visible even when Display property is set to False. Any idea?
Thanks a lot.
Cheers,
Milan G
8 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 07 Jan 2009, 01:07 PM
Hello Milan,
Try the following code (for instance in the page load event) to hide the EditItemTemplate as such for the TemplateColumn:
cs:
Another suggestion is to hide the TextBox in the EditItemTemplate of the TemplateColumn in EditMode, using the following code.
cs:
Thanks
Princy.
Try the following code (for instance in the page load event) to hide the EditItemTemplate as such for the TemplateColumn:
cs:
GridTemplateColumn column = (GridTemplateColumn)RadGrid1.MasterTableView.GetColumnSafe("InvoiceDetailID"); |
column.EditItemTemplate = null; |
Another suggestion is to hide the TextBox in the EditItemTemplate of the TemplateColumn in EditMode, using the following code.
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem item=(GridEditableItem)e.Item; |
TextBox txtbox = (TextBox)item["InvoiceDetailID"].FindControl("txtInvoiceDetailID"); |
txtbox.Visible = false; |
} |
} |
Thanks
Princy.
0

Milan Gurung
Top achievements
Rank 1
answered on 07 Jan 2009, 02:08 PM
Princy,
Thanks for the earlier help - the trouble now is the eventhough textbox is invisible, its corresponding label is still dangling around.
Any idea? I tried following but didn't work.
If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
Dim eItem As GridEditableItem = e.Item
CType(eItem("InvoiceDetailID").FindControl("txtInvoiceDetailID"), TextBox).Visible = False
Item("InvoiceDetailID").Visible = False
End If
On trying this, I got NULL Exception :(
CType(eItem("InvoiceDetailID").FindControl("lbInvoiceDetailID"), Lable).Visible = False
Any suggestion?
Cheers,
Milan G
0

Steve Y
Top achievements
Rank 2
answered on 07 Jan 2009, 03:34 PM
Hi Milan,
I think if you make the template column display="false" and readonly="true" you should get what you need. Also, unless you have a specific need for it that I don't understand from your code, you shouldn't declare the EditItemTemplate for this field as you're not using it...
Regards, Steve
I think if you make the template column display="false" and readonly="true" you should get what you need. Also, unless you have a specific need for it that I don't understand from your code, you shouldn't declare the EditItemTemplate for this field as you're not using it...
<Columns> |
<telerik:GridTemplateColumn DataField="InvoiceDetailID" HeaderText="InvoiceDetailID" UniqueName="InvoiceDetailID" Display="false" ReadOnly="true"> |
<ItemTemplate> |
<asp:Label ID="lblInvoiceDetailID" runat="server" Text='<%# Bind("InvoiceDetailID") %>' >' </asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
Regards, Steve
0

Milan Gurung
Top achievements
Rank 1
answered on 07 Jan 2009, 03:53 PM
Hi Steve,
ReadOnly property doesn't exist. Help me out.
FYI,I need store the "InvoiceDetailID" so that I can update the record based it.
Thanks.
Milan G
ReadOnly property doesn't exist. Help me out.
FYI,I need store the "InvoiceDetailID" so that I can update the record based it.
Thanks.
Milan G
0

Steve Y
Top achievements
Rank 2
answered on 07 Jan 2009, 04:00 PM
Hmm. I just tried a test of what I suggested and it works fine for me.
Here's what I put into a quick grid...
It worked exactly as I expected and does what you are looking for.
Are you using RadControls for ASP.NET AJAX? What version do you have?
Regards, Steve
Here's what I put into a quick grid...
<Columns> |
<Telerik:GridBoundColumn DataField="LeadNameId" DataType="System.Int32" |
HeaderText="LeadNameId" ReadOnly="True" SortExpression="LeadNameId" |
UniqueName="LeadNameId"> |
</Telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="TeamId" HeaderText="TeamId" UniqueName="TeamId" Display="false" ReadOnly="true"> |
<ItemTemplate> |
<asp:Label ID="TeamId" runat="server" Text='<%# Bind("TeamId") %>' >' </asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<asp:TextBox ID="TeamId" Text='<%# Bind("TeamId") %>' runat="server" ReadOnly="true"></asp:TextBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<Telerik:GridBoundColumn DataField="LeadName" HeaderText="LeadName" |
SortExpression="LeadName" UniqueName="LeadName"> |
</Telerik:GridBoundColumn> |
</Columns> |
It worked exactly as I expected and does what you are looking for.
Are you using RadControls for ASP.NET AJAX? What version do you have?
Regards, Steve
0

Milan Gurung
Top achievements
Rank 1
answered on 07 Jan 2009, 04:08 PM
Hi Steve,
I rechecked my code - ReadOnly Property is not allowed for GridTemplateColumn. I using ASP.NET Ajax Q2 2008 VERSION: 2008.2.723.20
Any idea why I am having a problem?
Thanks a lot.
Cheers,
Milan G
I rechecked my code - ReadOnly Property is not allowed for GridTemplateColumn. I using ASP.NET Ajax Q2 2008 VERSION: 2008.2.723.20
Any idea why I am having a problem?
Thanks a lot.
Cheers,
Milan G
0

Steve Y
Top achievements
Rank 2
answered on 07 Jan 2009, 04:24 PM
ReadOnly for GridTemplateColumn was added in Q3 2008 release. Check out the release notes here.
http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q3-2008-version-number-2008-3-1105.aspx
Regards, Steve
http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q3-2008-version-number-2008-3-1105.aspx
Regards, Steve
0

Milan Gurung
Top achievements
Rank 1
answered on 07 Jan 2009, 04:27 PM
Steve,
Many thanks indeed. I will have a look into it.
Cheers,
Milan G
Many thanks indeed. I will have a look into it.
Cheers,
Milan G