SIGABRT Issue in valgrind with multithreading in c++11 - multithreading

class MyClass{
public :
void runBscGwThread(int);
private :
std::unique_ptr<std::thread> MyClass_;
}
MyClass::Myclass(int bcfId, A::AParam sctpParams):
bcfId_(bcfId),
{
Myclass_.reset(new std::thread([this](){ this->runBscGwThread(bcfId_);}));
}
This issue is seen occasionally . In destructor I am doing
Myclass:: ~Myclass(){
if (Myclass_->joinable)
Myclass_->join();
}
The Valgrind Logs are below :
fatal_signal>
<tid>2</tid>
<signo>6</signo>
<signame>SIGABRT</signame>
<sicode>-6</sicode>
<stack>
<frame>
<ip>0x670DB80</ip
/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libc-2.24.so
<fn>raise</fn>
</frame>
<frame>
<ip>0x670F046</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libc-2.24.so</obj>
<fn>abort</fn>
</frame>
<frame>
<ip>0x656831E</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__gnu_cxx::__verbose_terminate_handler()</fn>
</frame>
<frame>
<ip>0x6565EC3</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x6564C28</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x6565426</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__gxx_personality_v0</fn>
</frame>
<frame>
<ip>0x66D941E</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libgcc_s.so.1</obj>
</frame>
<frame>
<ip>0x66D974C</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libgcc_s.so.1</obj>
<fn>_Unwind_RaiseException</fn>
</frame>
<frame>
<ip>0x65661E3</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>__cxa_throw</fn>
</frame>
<frame>
<ip>0x65913F2</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>std::__throw_system_error(int)</fn>
</frame>
<frame>
<ip>0x6593917</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
<fn>std::thread::join()</fn>
</frame>
<frame>
<ip>0x8083F41</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::stop()</fn>
</frame>
<frame>
<ip>0x8083F69</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::~Myclass()</fn>
</frame>
<frame>
<ip>0x807DD62</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count()</fn>
</frame>
<frame>
<ip>0x807E15E</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::_Rb_tree<int, std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > >, std::_Select1st<std::pair<int const, std::pair<, std::shared_ptr<GTS::BSCGW::Myclass> > > >, std::less<int>, std::allocator<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > > >::_M_erase(std::_Rb_tree_node<std::pair<int const, std::pair<std::shared_ptr< std::shared_ptr<GTS::BSCGW::Myclass> > > >*)</fn>
</frame>
<frame>
<ip>0x807E150</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::_Rb_tree<int, std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > >, std::_Select1st<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > >, std::less<int>, std::allocator<std::pair<int const, std::pair<std::shared_ptr<, std::shared_ptr<GTS::BSCGW::Myclass> > > > >::_M_erase(std::_Rb_tree_node<std::pair<int const, std::shared_ptr<GTS::BSCGW::Myclass> > > >*)</fn>
</frame>
<frame>
<ip>0x8084928</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::readFromSocket(std::vector<unsigned char, std::allocator<unsigned char> >&, int)</fn>
</frame>
<frame>
<ip>0x8085142</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>GTS::BSCGW::Myclass::runBscGwThread(int)</fn>
</frame>
<frame>
<ip>0x80852A6</ip>
<obj>/dev/shm/workspace/GTS+trunk.x86.VALGRIND.UT/build/x86/gts/test/ut/tests/BscGw/GTS-BscGw-UT</obj>
<fn>std::thread::_Impl<std::_Bind_simple<GTS::BSCGW::Myclass::Myclass(int, GTS::AbisSctpParam)::{lambda()#1} ()> >::_M_run()</fn>
</frame>
<frame>
<ip>0x6593A8D</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libstdc++.so.6.0.22</obj>
</frame>
<frame>
<ip>0x64DD2E9</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libpthread-2.24.so</obj>
<fn>start_thread</fn>
</frame>
<frame>
<ip>0x67C90ED</ip>
<obj>/build/ltesdkroot/data/Platforms/IB_PS_LFS_REL/IB013_PS_LFS_REL_2017_06_0017-LTE/IB013_PS_LFS_REL_2017_06_0017-LTE/os/sys-root/i686-pc-linux-gnu/usr/lib/libc-2.24.so</obj>
<fn>clone</fn>
</frame>

Myclass:: ~Myclass(){
if (Myclass_->joinable)
Myclass_->join();
}
Since you have kept the thread as joinable, the calling thread waits for its completion.
Is it necessary for you to keep the thread Joinable, if there is no concurrent access to a resource , you can allow these threads to run in parallel.

Related

Xamarin Form - How To checked the checkbox on another check box checked in UWP

My application displays the fetures permissions on DataGrid from database. For realizing this I am using the MyToolkit.Controls.DataGrid. Now i want output for if user checked the admin or update/delete/create check box then View and list check box checked vice versa same for the and also i want to set checkbox checked value from database.
thanks in advance.
Image
if user checked the create/update/delete then same row list and view should be checkbox checked
if user checked the view check box then selected row column list should be checked
Datagrid xaml
<Toolkit:DataGrid.Columns >
<!--Feature Column-->
<Toolkit:DataGridTemplatedColumn CanSort="False" >
<Toolkit:DataGridTemplatedColumn.Header>
<TextBlock FontSize="16" Foreground="#000000" Width="280" Text="Feature" />
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<TextBlock FontSize="14" Padding="6 0 0 0" Foreground="#333333" Width="280" Text="{Binding featureName}"/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!--Create-->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False" >
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1 0 0 0" >
<TextBlock FontSize="16" Padding="0" Foreground="#000000" Text=" Create" />
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<CheckBox Margin="30,0,0,0" Style="{StaticResource CheckBoxStyle1}" x:Name="CBCreate" DataContext="create" Tag ="{Binding featureId}" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Checked="CBCreate_Checked" />
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!--Update-->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False" >
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1 0 0 0" >
<TextBlock FontSize="16" Foreground="#000000" Text=" Update" />
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<CheckBox Margin="30 0 0 0" Style="{StaticResource CheckBoxStyle1}" IsChecked="{Binding Update}" x:Name="CBUpdate" DataContext="update" Tag ="{Binding featureId}" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" />
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!--Delete-->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False" >
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1 0 0 0" >
<TextBlock FontSize="16" Foreground="#000000" Text=" Delete" />
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<CheckBox Margin="30,0,0,0" Style="{StaticResource CheckBoxStyle1}" IsChecked="{Binding Delete}" x:Name="CBDelete" DataContext="delete" Tag ="{Binding featureId}" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" />
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!--View-->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False" >
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1 0 0 0" >
<TextBlock FontSize="16" Foreground="#000000" Text=" View" />
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<CheckBox Checked="CBView_Checked" Unchecked="CBView_Unchecked" IsChecked="{Binding View}" Indeterminate="CBView_Indeterminate" Margin="30,0,0,0" Style="{StaticResource CheckBoxStyle1}" x:Name="view" DataContext="{Binding featureName}" Tag ="view" AccessKey="{Binding index}" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" />
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!--List-->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False" x:Name="CLMList" >
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1 0 0 0" >
<TextBlock FontSize="16" Foreground="#000000" Text=" List" />
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate >
<CheckBox x:FieldModifier="public" IsChecked="{Binding List}" Margin="30,0,0,0" Style="{StaticResource CheckBoxStyle1}" x:Name="CBList" DataContext="list" Tag ="{Binding featureId}" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Unchecked="CBList_Unchecked" Checked="CBList_Checked" />
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
</Toolkit:DataGrid.Columns>
</Toolkit:DataGrid>
in simple way if user click on update/create/delete check boxes then list and view check box row should be checked AND if user checked the view checkbox then List checkbox should be checked.
For your requirement, you could use two way bind to realize. For details code please refer the following. The following code was modified base on your provided demo, you could copy and replace directly.
FeatureData class
public class FeatureData : INotifyPropertyChanged
{
public int featureId { get; set; }
public string featureName { get; set; }
private bool _create;
public bool Create
{
get { return _create; }
set
{
_create = value;
UpdateViewAndList(value);
OnChanged();
}
}
private bool _update;
public bool Update
{
get { return _update; }
set
{
_update = value;
UpdateViewAndList(value);
OnChanged();
}
}
private bool _delete;
public bool Delete
{
get { return _delete; }
set
{
_delete = value;
UpdateViewAndList(value);
OnChanged();
}
}
private bool _list;
public bool List
{
get { return _list; }
set
{
_list = value;
OnChanged();
}
}
private bool _view;
public bool View
{
get { return _view; }
set
{
_view = value;
this.List = value;
OnChanged();
}
}
private void UpdateViewAndList(bool value)
{
if (value)
{
this.View = true;
this.List = true;
}
else
{
this.View = false;
this.List = false;
}
}
//public string index { get; set; }
public FeatureData(bool Create, bool Update, bool Delete, bool List, bool View, int featureId, string featureName)
{
this.featureId = featureId;
this.featureName = featureName;
this.Create = Create;
this.Update = Update;
this.Delete = Delete;
this.List = List;
this.View = View;
//this.index = index;
}
private bool _IsSelected = false;
public bool IsSelected { get { return _IsSelected; } set { _IsSelected = value; OnChanged("IsSelected"); } }
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnChanged([CallerMemberName]string prop = null)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(prop));
}
#endregion
}
Xaml bind
<Toolkit:DataGrid.Columns>
<!-- Feature Column -->
<Toolkit:DataGridTemplatedColumn CanSort="False">
<Toolkit:DataGridTemplatedColumn.Header>
<TextBlock
Width="280"
FontSize="16"
Foreground="#000000"
Text="Feature"
/>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<TextBlock
Width="280"
Padding="6,0,0,0"
FontSize="14"
Foreground="#333333"
Text="{Binding featureName}"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!-- Create -->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False">
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<TextBlock
Margin="15,0,0,0"
Padding="0"
FontSize="16"
Foreground="#000000"
Text="Create"
/>
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<CheckBox
x:Name="CBCreate"
Margin="30,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
IsChecked="{Binding Create,Mode=TwoWay}"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!-- Update -->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False">
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<TextBlock
FontSize="16"
Foreground="#000000"
Text=" Update"
/>
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<CheckBox
x:Name="CBUpdate"
Margin="30,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
IsChecked="{Binding Update, Mode=TwoWay}"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!-- Delete -->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False">
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<TextBlock
FontSize="16"
Foreground="#000000"
Text=" Delete"
/>
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<CheckBox
x:Name="CBDelete"
Margin="30,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
IsChecked="{Binding Delete, Mode=TwoWay}"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!-- View -->
<Toolkit:DataGridTemplatedColumn Width="180" CanSort="False">
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<TextBlock
FontSize="16"
Foreground="#000000"
Text=" View"
/>
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<CheckBox
x:Name="view"
Margin="30,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
IsChecked="{Binding View, Mode=TwoWay}"
Tag="view"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
<!-- List -->
<Toolkit:DataGridTemplatedColumn
x:Name="CLMList"
Width="180"
CanSort="False"
>
<Toolkit:DataGridTemplatedColumn.Header>
<Border BorderBrush="Black" BorderThickness="1,0,0,0">
<TextBlock
FontSize="16"
Foreground="#000000"
Text=" List"
/>
</Border>
</Toolkit:DataGridTemplatedColumn.Header>
<Toolkit:DataGridTemplatedColumn.CellTemplate>
<DataTemplate>
<CheckBox
x:Name="CBList"
Margin="30,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
x:FieldModifier="public"
IsChecked="{Binding List, Mode=TwoWay}"
/>
</DataTemplate>
</Toolkit:DataGridTemplatedColumn.CellTemplate>
</Toolkit:DataGridTemplatedColumn>
</Toolkit:DataGrid.Columns>

Alternative Color for Gridview Row in Xamarin Forms

I am trying to make alternative row color in Xamarin Gridview, unfortunately it is not working, can you anyone please see what mistake I am ding here.
I went through few articles and all they suggest to use converter to make alternative row color.
namespace CommonUI.Utilities
{
public class AlternatingHighlightColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Color rowcolor = Color.Transparent;
if (value == null || parameter == null) return Color.White;
var index = ((ListView)parameter).ItemsSource.Cast<object>().ToList().IndexOf(value);
if (index % 2 == 0)
{
rowcolor = Color.Pink;
}
return rowcolor;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:U="clr-namespace:CommonUI.Utilities"
x:Class="CommonUI.Views.MyProfile"
Title="My Profile" >
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" Padding="2" Spacing="10" BackgroundColor="#DCE4EA">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" Spacing="1">
<Grid BackgroundColor="#CFD9E1" Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="85"/>
<ColumnDefinition Width="45"/>
</Grid.ColumnDefinitions>
<Label Text="Aircraft" FontSize="13" TextColor="Black" Grid.Row="0" Grid.Column="0" XAlign="Start" YAlign="Center"/>
<Label Text="Date Created" FontSize="13" TextColor="Black" Grid.Row="0" Grid.Column="1" XAlign="Start" YAlign="Center"/>
<Label Text="Actions" FontSize="13" TextColor="Black" Grid.Row="0" Grid.Column="2" XAlign="Center" YAlign="Center"/>
</Grid>
<ListView x:Name="listView" ItemsSource="{Binding ProfileList}" SeparatorVisibility="Default" SeparatorColor="#DCE4EA">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="{Binding .,Converter={StaticResource U:AlternatingHighlightColorConverter}, ConverterParameter={x:Reference listView}}" Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>

How to bind dropdownlist in radgrid

I am new to use telerik controls. I want to bind data in dropdownlist that is in telerik RadGrid control. I have already been applied but it gives an error
Object reference not set to an instance of an object.
Here is my code given below :
Source code
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true"
OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand"
OnItemCreated="RadGrid1_ItemCreated" OnDeleteCommand="RadGrid1_DeleteCommand"
OnInsertCommand="RadGrid1_InsertCommand"
onitemdatabound="RadGrid1_ItemDataBound" >
<MasterTableView DataKeyNames="id" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" />
<telerik:GridBoundColumn DataField="id" HeaderText="ID" ReadOnly="true"
ForceExtractValue="Always" ConvertEmptyStringToNull="true" />
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="ddldept" DataTextField="name" DataValueField="id" runat="server"></asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="code" HeaderText="Branch Code" />
<telerik:GridBoundColumn DataField="name" HeaderText="Branch Name" />
<telerik:GridBoundColumn DataField="shortname" HeaderText="Branch Shorth Name" />
<telerik:GridBoundColumn DataField="hod" HeaderText="Head of Department"/>
<telerik:GridBoundColumn DataField="location" HeaderText="Location Address" />
<telerik:GridButtonColumn ConfirmText="Are you sure want to delete this Branch?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
</Columns>
<EditFormSettings>
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric" />
<ClientSettings>
<ClientEvents OnRowDblClick="rowDblClick" />
</ClientSettings>
</telerik:RadGrid>
Main Code
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
DataTable dt=obj.display_branch();
GridEditableItem item = e.Item as GridEditableItem;
DropDownList list = item.FindControl("ddldept") as DropDownList;
list.DataSource = dt;
list.DataTextField = "name";
list.DataValueField = "id";
list.DataBind();
}
Try on RadGrid1_ItemCreated. That is how I achieved it.

Update row in Gridview?

I have updated a row in Gridview but it is not working.
Here is my code :
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
//Label lbldeleteid = (Label)row.FindControl("Label1");
string bname= GridView1.DataKeys[e.RowIndex].Values["manufacturer"].ToString();
TextBox tbmanu = (TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[1];
var myString = tbmanu.ToString();
SqlCommand cmd = new SqlCommand("manu_upd",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#manufacturer", SqlDbType.NVarChar,100);
cmd.Parameters["#manufacturer"].Value = myString;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
BindData();
I got the following error :
Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.TextBox'.
here is my Grid view :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="manufacturer" ForeColor="#333333"
GridLines="None" Width="400px" BorderStyle="Double"
CellSpacing="3" Font-Bold="True" Font-Size="Small" ShowFooter="True"
ShowHeaderWhenEmpty="True" onrowdeleting="GridView1_RowDeleting"
onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"
onrowcancelingedit="GridView1_RowCancelingEdit"
AutoGenerateEditButton="True">
<AlternatingRowStyle BackColor="White"/>
<Columns>
<asp:TemplateField HeaderText="Number" ItemStyle-
HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lbnaumber" runat="server" Text='<%#
Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Manufacturer"
SortExpression="manufacturer">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("manufacturer") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbmanu" runat="server" Text='<%#
Bind("manufacturer") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<%--<asp:CommandField ShowEditButton="True" />--%>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF"/><FooterStyle BackColor="#507CD1"
Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"/>
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" /><SelectedRowStyle BackColor="#D1DDF1"
Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB"/>
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
When I change the index of my text box 1 to 3 it shows me below error :
Specified argument was out of the range of valid values.
Parameter name: index
When i change its index 3 to 2 it gives me below error :
Unable to cast object of type 'System.Web.UI.WebControls.DataControlLinkButton' to type 'System.Web.UI.WebControls.TextBox'.
I have one required field validator in my form but when I enable that validation update in grid view is not working.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
TextBox tbmanu1 = (TextBox)row.FindControl("tbmanu");
//or try
//TextBox tbmanu1= (TextBox)row.Cells[0].FindControl("tbmanu");
string myString = Convert.Tostring(tbmanu1.text);
cmd.Parameters["#manufacturer"].Value = myString;
}
Try wrapping your gridview in a asp:UpdatePanel and set the update mode to conditional.
Good Luck

javax.xml.ws.WebServiceException: java.lang.RuntimeException: Incorrect inclusion value: null

I developed web services using CXF. Today i added the simple user name token security for the web service. After that when i try to deploy the web service i am getting following exception
javax.xml.ws.WebServiceException: java.lang.RuntimeException: Incorrect inclusion value: null
Failed to build the policy 'UsernameToken':Incorrect inclusion value: null
I am using Jboss 6 . The following is my policy snippet i have added in the wsdl file.
<wsp:Policy wsu:Id="UsernameToken"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:ExactlyOne>
<wsp:All>
<!-- Empty <TransportBinding/> element required due to bug in CXF 2.2.6 -->
<sp:TransportBinding />
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken=".../IncludeToken/AlwaysToRecipient" />
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
The following is my cxf.xml file
<jaxws:endpoint id="UpcLineOfBusinessServiceImpl"
address="/upcLineOfBusinessService" wsdlLocation="../wsdl/upclineofbusinessserviceimpl.wsdl">
<jaxws:implementor>
<ref bean="upcLineOfBusinessService"></ref>
</jaxws:implementor>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackClass" value="com.tecnotree.upc.security.PasswordCallBack" />
</map>
</constructor-arg>
</bean>
</jaxws:inInterceptors>
</jaxws:endpoint>
Please help me . Thanks in advance
I've recently come across the same exception. The problem was incorrect sp:IncludeToken value. After I changed it to http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient everything worked fine.
Available values are defined in org.apache.cxf.ws.security.policy.SP12Constants (for WS-SecurityPolicy 1.2) or in org.apache.cxf.ws.security.policy.SP11Constants (for 1.1)
Complete policy definition looks like this:
<wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:UsernameToken
sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10 />
<sp:HashPassword />
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>

Resources