2

このエラーは非常に頻繁に発生しますが、毎回ではありません。

Object reference not set to an instance of an object.

私は次のコードを使用しています:

Category n = new Category { 
                     ID = id, 
                     name = TxtName.Text, 
                     TopNav = Convert.ToInt32(Chk_Top.SelectedItem.Value), 
                     LeftNav = Convert.ToByte(Chk_Left.Checked ? "1" : "0"), 
                     Active = Convert.ToByte(Chk_Active.Checked ? "1" : "0"), 
                     Rank = Convert.ToInt32(Txt_position.Text), 
                     ParentID = pid, 
                     Image = name, 
                     Content = Content.Text, 
                     PageTitle = Txt_SpeakerTitle.Text, 
                     PageName = Txt_SpeakerTitle.Text, 
                     speakerpreview = Txt_Previewdesc.Text, 
                     PageDesc = Txt_SpeakerTitle.Text, 
                     PageKeyword = Txt_SpeakerTitle.Text, 
                     Filehandler = "speaker", 
                     SpeakerDetail = speakerdesc.Text, 
                     SpeakerTitle = Txt_SpeakerTitle.Text, 
                     SpotLightdesc = spotlightcontent.Text, 
                     Chk_Spot = Convert.ToByte(Chk_Spot.Checked ? "1" : "0"),
                     Catalogue = Catalogue };

db.Categories.InsertOnSubmit(n);

提案してください。前もって感謝します。

4

1 に答える 1