这是我的代码:
asp.cs
if (!IsPostBack) { string getEmp = "Select employeeID,photo,lastname,firstname,departmentname,designation,userType from tblEmployee e inner join tblDepartment d on d.departmentID=e.department"; sqlCommand com = new sqlCommand(getEmp,con); con.open(); sqlDataReader dr = com.ExecuteReader(); button btnSet = (button)FindControl("btnSet"); if (dr.HasRows) { if (dr.Read()) { if (btnSet != null) { if (dr["userType"].ToString() == "2") { btnSet.Text = "Set as normal User"; } else { btnSet.Text = "Set as Power User"; } } } } Repeater1.DataSource = dr; Repeater1.DataBind(); dr.dispose(); con.Close();
ASPX
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sqlDataSource1"><asp:button ID="btnSet" commandname="set" commandargument=<%# Eval ("employeeID") %> runat="server" Text="" />解决方法 尝试这太短暂和工作
<asp:button ID="btnSet" commandname="set" commandargument=<%# Eval("employeeID") %> runat="server" Text='<%# Eval("userType").ToString() == "2" ?"Set as normal User" : "Set as Power User" %>' />
如果您需要更多帮助,请告诉我
总结以上是内存溢出为你收集整理的c# – asp转发器按钮文本更改全部内容,希望文章能够帮你解决c# – asp转发器按钮文本更改所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)