本文介绍了参数值不从后面的代码传递给数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个带有selectcommand的gridview作为storedprocedure。我想在按钮点击期间从后面的代码传递参数值。但是值没有通过。任何帮助都将是非常感谢。谢谢。
我尝试过:
< asp:SqlDataSource ID =SqlDataSource2runat =serverConnectionString =<%$ ConnectionStrings:EMPYHT_ConnectionString%>
SelectCommand =SPGETNAMESSelectCommandType =StoredProcedure>< SelectParameters>
< asp:参数名称=tnidType =StringDefaultValue =/>
< / SelectParameters>
< / asp:SqlDataSource>
protected void but_mep_Click(object sender,EventArgs e )
{
string tende = Session [TENDER]。ToString();
SqlDataSource2.SelectParameters [tnid]。DefaultValue = tende;
grd_tendermedicineslist.DataBind();
upnl_editquo.Update();
}
解决方案
Hi all,
I have a gridview with selectcommand as storedprocedure .I want to pass a parameter value to SP from code behind during a buttonclick .However the value is not passing.Any help will be really appreciated.Thanks in advance.
What I have tried:
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:EMPYHT_ConnectionString %>" SelectCommand="SPGETNAMES" SelectCommandType="StoredProcedure"><SelectParameters> <asp:Parameter Name="tnid" Type="String" DefaultValue="" /> </SelectParameters> </asp:SqlDataSource>
protected void but_mep_Click(object sender, EventArgs e) { string tende=Session["TENDER"].ToString(); SqlDataSource2.SelectParameters["tnid"].DefaultValue = tende; grd_tendermedicineslist.DataBind(); upnl_editquo.Update(); }
解决方案
这篇关于参数值不从后面的代码传递给数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!