c# – 从asp.net中的dataSet获取一个值
发布时间:2020-12-15 04:30:42 所属栏目:百科 来源:网络整理
导读:我正在从tbl_message表中做一个查询以获取Title和RespondBY,我要在对数据中继器进行数据绑定之前解密Title.在做数据库之前,如何访问标题值. string MysqlStatement = "SELECT Title,RespondBy FROM tbl_message WHERE tbl_message.MsgID = @MsgID";using (Da
我正在从tbl_message表中做一个查询以获取Title和RespondBY,我要在对数据中继器进行数据绑定之前解密Title.在做数据库之前,如何访问标题值.
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> 解决方法
可能,像下面的代码部分,你可以得到标题,然后尝试这个编码
rptList.DataSource = ds; rptList.DataBind(); 以下代码部分可以从dataset获取标题 string title = ds.Tables[0].Rows[0]["Title"].ToString(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |