如何使用数据读取器在ASP.NET中为buuton添加commandname和commandargument值 [英] How to add commandname and commandargument value for buuton in ASP.NET using data reader
本文介绍了如何使用数据读取器在ASP.NET中为buuton添加commandname和commandargument值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%MySqlCommand cmd = new MySqlCommand(sql,conn);
MySqlDataReader read = cmd.ExecuteReader();
while(read.Read())
{%>
< asp:按钮 ID = btnsubmit OnClick = btnsubmitonclick < span class =code-attribute> class = btn btn-primary < span class =code-attribute> runat = server tabindex = 4 < span class =code-attribute> 文本 = 立即升级 / >
我尝试过:
上面的按钮我需要使用read [0] value
解决方案
添加commandname和commandargument值可能你的意思是这个(转到View代码):
受保护 void Page_Load ( object sender,EventArgs e)
{
btnsubmit.CommandName = < span class =code-string> BlaBlaBla;
btnsubmit.CommandArgument = Hehehe;
}
< < span class =code-leadattribute> asp:按钮 ID = btnsubmit OnClick = btnsubmitonclick class = btn btn-primary runat = server tabindex = 4 文本 = 立即升级 CommandName = BlaBlaBla CommandArgument = HeHeHe / > 跨度>
<% MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader read = cmd.ExecuteReader();
while(read.Read())
{%>
<asp:Button ID="btnsubmit" OnClick="btnsubmitonclick" class="btn btn-primary" runat="server" tabindex="4" Text="Upgrade Now" />
What I have tried:
for the above button i need to add commandname and commandargument value using read[0] value
解决方案
Probably you mean this (go to View Code):
protected void Page_Load(object sender, EventArgs e) { btnsubmit.CommandName = "BlaBlaBla"; btnsubmit.CommandArgument = "Hehehe"; }
<asp:Button ID="btnsubmit" OnClick="btnsubmitonclick" class="btn btn-primary" runat="server" tabindex="4" Text="Upgrade Now" CommandName="BlaBlaBla" CommandArgument="HeHeHe"/>
这篇关于如何使用数据读取器在ASP.NET中为buuton添加commandname和commandargument值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文