【发布时间】:2013-11-05 19:16:59
【问题描述】:
我在 GridView 中有一个列,在某些单元格中有一个值,而其他单元格的 NULL 表示为空,所以我需要为空单元格设置一个默认值,而不需要对有数据的单元格进行任何更改,表示我想将 NULL 值更改为某些数据的任何空单元格,让我们将其设置为“无数据”。 请帮忙,我该怎么做?
我通过下一个代码从 SQL 中获取数据
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"];
}
【问题讨论】:
标签: c# datagridview sql-server-2008-r2