简体   繁体   English

将Guid值分配给C#变量,即字符串

[英]Assign Guid value to C# variable i.e. string

I am trying to capture GUID value and store in string variable but getting null value 我正在尝试捕获GUID值并存储在字符串变量中,但得到空值

Model 模型

public string StudentRemediationSignatureCheckGuid { get; set; }

ContextSession give me GUID value which I like to assign to variable above define ContextSession给我要分配给上面定义的变量的GUID值

_assessmentRemidationObject.StudentRemediationSignatureCheckGuid = ContextSession.GUID.ToString(); 

update code 更新代码

  public string SeniorAssessorGuid = string.Empty; //global variable


 protected void checkBoxSeniorAssessorSignature_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox SelectedCheckBoxObject4 = (CheckBox)sender;

        if (SelectedCheckBoxObject4.Checked)
        {

            TxtBoxSeniorAssessorSignatureDate.Text = System.DateTime.Now.ToString("d/M/yyyy");

            _assessmentRemidationObject.SeniorAssessorSignatureCheckGuid = ContextSession.GUID.ToString(); 
            SeniorAssessorGuid = ContextSession.GUID.ToString(); 
        }
        else if (!SelectedCheckBoxObject4.Checked)
        {
            TxtBoxSeniorAssessorSignatureDate.Text = string.Empty;

        }
    }

Do not store the value of the ContextSession.GUID in a member of your page _assessmentRemidationObject if you loose its value. 如果_assessmentRemidationObject ContextSession.GUID的值,请勿将其存储在页面_assessmentRemidationObject的成员中。 You need to use a global variable or a persistent storage (a database for example). 您需要使用全局变量或永久性存储(例如数据库)。 Try to find where _assessmentRemidationObject is resetted before you read it. 尝试在读取_assessmentRemidationObject之前将其重置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中通过String调用构造函数(即通过Reflection)? - How to invoke Constructors by String in C# (i.e. by Reflection)? c#中的扩展方法如何为父变量赋值,即“this”变量 - Extension methods in c# how to assign value to the parent variable i.e the “this” variable 如何在asp.net mvc中使用razor viewmodel将c#guid值赋给javascript变量? - How to assign c# guid value to javascript variable using razor viewmodel in asp.net mvc? 什么时候应该使用数组列表(即列表) <string []> =新清单 <string []> ())在C#中? - When should I use List of Array (i.e. List<string []> = new List<string []>()) in C#? c#:如何将字符串转换为自定义模板类型(即实现“T convertTo <T> (串)”) - c#: how to convert string to custom template type (i.e. implement “T convertTo<T>(string)”) 通过在 C# 中注入 object 值(即使用反射)来解析字符串公式 - Parsing a string formula by injecting object values (i.e. using reflection) in C# 从C#中的多个异步方法(即线程)增加值类型 - Increase a value type from multiple async methods (i.e. threads) in C# 如何将字典键和值作为字符串C#分配给变量 - How to assign a dictionary key and value to a variable as a string C# 从数据库检索值并将其分配给字符串变量C# - retrieve value from database and assign it in to string variable C# 从数据库中检索日期值并将其分配给字符串变量 C# - Retrieve date value from database and assign it in to string variable C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM