I have a column in the GridView, in some cells there is a value, and in other cells it is NULL, so I need to put the default value in empty cells without any changes in the cells that have data, means that any empty cells I want to change the NULL value for some data, and we put it as "No data". Please help, how can I do this?
I get data from SQL with the following code
public void showVolunteers(int x)
{
SqlCommand com = new SqlCommand("SELECT [Vol_ID]as[م],[Vol_Name]as[الاسم],[Team_Info].[team_name]as[منتمي الى فريق],[Vol_Zone]as[المنطقة],[vol_street]as[الحي],case [Vol_Sex] when '0' then 'ذكر' when'1' then 'انثى' end as[الجنس],[Vol_Date_of_Birth]as[تاريخ الميلاد],[Vol_Home_Phone]as[هاتف المنزل],[Vol_Work_Phone]as[هاتف العمل],[Vol_Mobile1]as[جوال1],[Vol_Mobile2]as[جوال2],[Vol_Email]as[الايميل],[Vol_Job]as[الوظيفة],[Vol_Affiliation]as[جهةالعمل],case [vol_Education] when '0' then 'لايوجد' when '1' then 'ابتدائي' when '2' then 'اعدادي' when '3' then 'ثانوي' when '5' then 'دبلوم تقني' when '6' then 'دبلوم مهني' when '7' then 'جامعي' when '8' then 'ماجستير' when '9' then 'دكتوراه' end as [المستوى التعليمي], [vol_Education_Place]as[المؤسسة التعليمية], [vol_Education_Department]as[التخصص], case [vol_Interesting] when '0' then 'لا يوجد' when '1' then 'صــحــي' when '2' then 'إجتــــماعــي' when '3' then 'تـــعليــم' when '4' then 'تــدريـــب' end as[الإهـــتمام], [vol_Hours]as[عدد ساعات التطوع], [vol_Notes]as[مــلاحظــات] FROM [VolunteersAffairs].[dbo].[Personal_info] left join [team_info] on [Personal_Info].[team_id] =[Team_info].[team_id]", con);
SqlDataAdapter da = new SqlDataAdapter();
DataSet dats = new DataSet();
da.SelectCommand = com;
da.Fill(dats, "Personal_Info");
dataGridViewX1.DataSource = dats.Tables["Personal_Info"];
}
source
share