Currently my Grid shows True, False, or N/A in the cell for boolean values. What would be the way so that I can get it to show Yes, No, or blank? The users are somehow getting confused by True/False/NA.
I'm populating the Grid using a SQLDataSource tied to a stored procedure in a 2005 SQLServer database. Also, I am using a RowEditTemplate where the value is tied to a radiobutton group.
Thanks,
Will
Yes you can use column template. Try to replace your code with the following:
<igtbl:TemplatedColumn Key="input_ops"> <Header> <RowLayoutColumnInfo OriginX="2" /> </Header> <CellTemplate> <asp:RadioButton ID="RadioButton1" runat="server" Text='<%# GetValue(Eval("input_ops").ToString())%>' Checked='<%# Eval("input_ops").ToString() == "True" ? true : false %>' /> </CellTemplate> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer></igtbl:TemplatedColumn>
After that put the following code in you code behind for example after page_load. Sorry in my first responce I made spelling error GetBool must be the same as GetValue:
protected string GetValue(string value) { if (value == "True")
{ return "Yes"; } else { if (value == "False") { return "No"; } } return "N/A";}
This method gets the Boolean value (input_ops) and return Yes, No or N/A.
Let me know if is working for you.
Mine's an UltraWebGrid. Can you use a Template column in a UWG?
<
igtbl:UltraGridColumn BaseColumnName="input_ops" IsBound="True" Key="input_ops">
Thanks for the code!
Where are we using the GetValue method though? Maybe I'm missing something.
Hello Will,
You can add a Template Field to WebDataGrid.Columns collection and put RadioButton in it.
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<ig:BoundDataField DataFieldName="id" Key="id">
<Header Text="id" />
</ig:BoundDataField>
<ig:TemplateDataField Key="TemplateField_0">
<ItemTemplate>
<asp:RadioButton ID="RadioButton1" runat="server" Text='<%# GetBool(Eval("IsChecked").ToString())%>' Checked='<%# Eval("IsChecked").ToString() == "True" ? true : false %>'/>
</ItemTemplate>
<Header Text="TemplateField_0" />
</ig:TemplateDataField>
</Columns>
</ig:WebDataGrid>
Also you have to add a method in code behind, which returns string value if the field is true, false or null:
protected string GetValue(string value)
{
if (value == "True")
return "Yes";
}
else
if (value == "False")
return "No";
return "Not Set";
Please let me know if you have any further questions with this matter.
Thank you
Sincerely,
Hristo Valyavicharski
Developer Support Engineer
Infragistics, Inc.
www.infragistcis.com/support