我正在进行查询以从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();
<table style="width: 498px; color: #F5F5F5;">
<asp:Repeater ID="rptList" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="15%">
<b>Subject</b>
</td>
<td width="60%">
<asp:Label ID="lbl_Subj" runat="server" Text='<%#Eval("Title")%>' />
</td>
</tr>
答案 0 :(得分:19)
或许,就像下面的代码部分一样,您可以在
之前获取标题并尝试编码rptList.DataSource = ds;
rptList.DataBind();
以下代码部分可以从dataset
获取标题string title = ds.Tables[0].Rows[0]["Title"].ToString();
答案 1 :(得分:3)
string title = ds.Tables [0] .Rows [0] [0] .ToString();
我使用了索引而不是标题名称。个人喜好。
答案 2 :(得分:0)
不确定解密是什么意思,但是如果你想通过在其上应用一些逻辑来修改Title,那么你可以创建一个以Title为输入并返回解密文本的方法,而不是用Title绑定文本。您可以将标签绑定到此方法,并将其传递给标题。