Hi..
Here i have two code snipets. In first i used bound column for displaying record in rad grid in runtime.
If i using template column its not working (It throughing an error like Data binding error).
My concept is IF i get the column from database means it should show the Data value Else column should be disappear.
PLEASE HELP ME ON THIS ISSUE... Thanks in advance.
WORKING
------------------------------------------------------
public void Bind_grid()
{
tkgvPerformance.Columns[0].Visible = false;
string Query = "select c.DepartmentID from tblEMP c";
tkgvPerformance.DataSource = Fs.GetDataTable(Query, CommandType.Text);
tkgvPerformance.DataBind();
}
<telerik:RadGrid ID="tkgvPerformance" runat="server" AutoGenerateColumns="False"
GridLines="None" Skin="Sunset" AllowFilteringByColumn="True" AllowSorting="True">
<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridBoundColumn DataField="EMPname" HeaderText="CourseName" UniqueName="CourseName">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Sub1">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%#Eval("DepartmentID") %>' ForeColor="Red"
Font-Bold="true" />
<telerik:RadNumericTextBox ID="txtPassMark" runat="server" MaxLength="3" Width="35px">
</telerik:RadNumericTextBox>
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MaxLength="3" Width="35px">
</telerik:RadNumericTextBox>
<asp:Label ID="Label1" runat="server" Text="100" ForeColor="Gray"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="style1" />
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
NOTWORKING
------------------------------------------------------
public void Bind_grid()
{
tkgvPerformance.Columns[1].Visible = false;
string Query = "select c.EMPname from tblEMP c";
tkgvPerformance.DataSource = Fs.GetDataTable(Query, CommandType.Text);
tkgvPerformance.DataBind();
}
<telerik:RadGrid ID="tkgvPerformance" runat="server" AutoGenerateColumns="False"
GridLines="None" Skin="Sunset" AllowFilteringByColumn="True" AllowSorting="True">
<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridBoundColumn DataField="EMPname" HeaderText="CourseName" UniqueName="CourseName">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Sub1">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%#Eval("DepartmentID") %>' ForeColor="Red"
Font-Bold="true" />
<telerik:RadNumericTextBox ID="txtPassMark" runat="server" MaxLength="3" Width="35px">
</telerik:RadNumericTextBox>
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MaxLength="3" Width="35px">
</telerik:RadNumericTextBox>
<asp:Label ID="Label1" runat="server" Text="100" ForeColor="Gray"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="style1" />
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>