从asp.net中的dataSet获取单个值

我正在进行查询以从tbl_message表中获取Title和RespondBY,我想在对数据绑定到转发器之前解密标题。 如何在执行数据绑定之前访问标题值。

string MysqlStatement = "SELECT Title, RespondBy FROM tbl_message WHERE tbl_message.MsgID = @MsgID"; using (DataServer server = new DataServer()) { MySqlParameter[] param = new MySqlParameter[1]; param[0] = new MySqlParameter("@MsgID", MySqlDbType.Int32); param[0].Value = MessageID; command.Parameters.AddWithValue("@MsgID", MessageID); ds = server.ExecuteQuery(CommandType.Text, MysqlStatement, param); } rptList.DataSource = ds; rptList.DataBind(); 

也许,就像下面的代码部分一样,您可以获得标题并在之前尝试此编码

 rptList.DataSource = ds; rptList.DataBind(); 

以下代码部分可以从数据集中获取标题

 string title = ds.Tables[0].Rows[0]["Title"].ToString(); 

string title = ds.Tables [0] .Rows [0] [0] .ToString();

我使用索引而不是标题名称。 个人喜好。

不确定你的意思是解密,但如果你想通过在其上应用一些逻辑来修改标题,那么你可以创建一个方法,将Title作为输入并返回解密的文本。 您可以将标签绑定到此方法,并将标题传递给它。

Subject <asp:Label ID="lbl_Subj" runat="server" Text='' />