ERIKA
چهارشنبه 23 فروردین 1391, 01:35 صبح
سلام
من میخاستم همچین کاری انجام بدم براش یک کدی نوشتم جواب نگرفتم
اين کلا به اين صورت که من يک خبر دارم که شامل يک سري گروه خبري هست ميخام به يوزر ها دسترسي به اين گروه خبري بدم و بعد وقتی میخاد خبر ها را ثبت کنه هر کسي به جز اون فرد نتوند به ساير گروه هاي خبر دسترسي داشته باشه
براي همين من اين کار رانجام دادم به ازاي يوزر هايي که ثبت ميشه همزمان با ثبت يوزر ها چک باکسی هایی که شامل گروه های خبری بود که گروه هاي خبري با يک ابجکت ديتا سورس پر شدند مياد انها را ثبت ميکنه
در واقع
ميخام همزمان که يوزر را ثبت ميکنه گروه هاي خبري که اين يوزر بهش دسترسي داره را هم ثبت کنم
چند تا جدول هم داریم
یکی جدول یوزر ها-جدول گروه های خبری- یک جدول هم به صورت واسط که یوزر نیم و نام گرو های خبری داخلش ثبت میشوند.
وقتی ثبت انجام میشه 2 تا ثبت انجام میشه یکسری اطلاعات یوزر ها در جدول یوزر ها و یکی هم یوزرنیم و گروه خبری در جدول اخری
من این کد را نوشتم ولی نتونستم جواب بگیرم
توی قسمت
findcontrol chekboxlist moshkel dare
میخاستم یک جور کد تغییرداده شود که عمل ثبت انجام بشه
ممنون
خطا:
System.NullReferenceException: Object reference not set to an instance of an object
public void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWiza rd1.UserName, true);
// Populate some Profile properties off of the create user wizard
p.name = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtName")).Text;
p.family = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtFamily")).Text;
p.identityNumber = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtIdentity")).Text;
p.nationalIdentityNumber = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtNationalIdentity")).Text;
p.fatherName = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtFatherName")).Text;
p.mobile = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtMobile")).Text;
p.tel = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtTel")).Text;
p.address = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtAddress")).Text;
p.stockNum = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtStockNum")).Text;
p.indebted = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtIndebted")).Text;
p.creditor = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtCreditor")).Text;
// Save the profile - must be done since we explicitly created this profile instance
p.Save();
string username = p.UserName;
CheckBoxList Chk = (CheckBoxList)FindControl("ChkBLNewsCat");
foreach (ListItem listitem in Chk.Items)
{
if (listitem.Selected)
{
ObjectDSUserAccessToNewsCat.InsertParameters["UserName"].DefaultValue = username;
ObjectDSUserAccessToNewsCat.InsertParameters["newsCatID"].DefaultValue = listitem.Value;
ObjectDSUserAccessToNewsCat.InsertParameters["newsCatName"].DefaultValue = listitem.Text;
ObjectDSUserAccessToNewsCat.Insert();
}
}
}
من میخاستم همچین کاری انجام بدم براش یک کدی نوشتم جواب نگرفتم
اين کلا به اين صورت که من يک خبر دارم که شامل يک سري گروه خبري هست ميخام به يوزر ها دسترسي به اين گروه خبري بدم و بعد وقتی میخاد خبر ها را ثبت کنه هر کسي به جز اون فرد نتوند به ساير گروه هاي خبر دسترسي داشته باشه
براي همين من اين کار رانجام دادم به ازاي يوزر هايي که ثبت ميشه همزمان با ثبت يوزر ها چک باکسی هایی که شامل گروه های خبری بود که گروه هاي خبري با يک ابجکت ديتا سورس پر شدند مياد انها را ثبت ميکنه
در واقع
ميخام همزمان که يوزر را ثبت ميکنه گروه هاي خبري که اين يوزر بهش دسترسي داره را هم ثبت کنم
چند تا جدول هم داریم
یکی جدول یوزر ها-جدول گروه های خبری- یک جدول هم به صورت واسط که یوزر نیم و نام گرو های خبری داخلش ثبت میشوند.
وقتی ثبت انجام میشه 2 تا ثبت انجام میشه یکسری اطلاعات یوزر ها در جدول یوزر ها و یکی هم یوزرنیم و گروه خبری در جدول اخری
من این کد را نوشتم ولی نتونستم جواب بگیرم
توی قسمت
findcontrol chekboxlist moshkel dare
میخاستم یک جور کد تغییرداده شود که عمل ثبت انجام بشه
ممنون
خطا:
System.NullReferenceException: Object reference not set to an instance of an object
public void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWiza rd1.UserName, true);
// Populate some Profile properties off of the create user wizard
p.name = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtName")).Text;
p.family = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtFamily")).Text;
p.identityNumber = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtIdentity")).Text;
p.nationalIdentityNumber = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtNationalIdentity")).Text;
p.fatherName = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtFatherName")).Text;
p.mobile = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtMobile")).Text;
p.tel = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtTel")).Text;
p.address = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtAddress")).Text;
p.stockNum = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtStockNum")).Text;
p.indebted = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtIndebted")).Text;
p.creditor = ((TextBox)CreateUserWizard1.CreateUserStep.Content TemplateContainer.FindControl("txtCreditor")).Text;
// Save the profile - must be done since we explicitly created this profile instance
p.Save();
string username = p.UserName;
CheckBoxList Chk = (CheckBoxList)FindControl("ChkBLNewsCat");
foreach (ListItem listitem in Chk.Items)
{
if (listitem.Selected)
{
ObjectDSUserAccessToNewsCat.InsertParameters["UserName"].DefaultValue = username;
ObjectDSUserAccessToNewsCat.InsertParameters["newsCatID"].DefaultValue = listitem.Value;
ObjectDSUserAccessToNewsCat.InsertParameters["newsCatName"].DefaultValue = listitem.Text;
ObjectDSUserAccessToNewsCat.Insert();
}
}
}