如何使用c#在asp.net中的静态方法中绑定转发器 [英] how to bind repeater in static method in asp.net with c#

查看:54
本文介绍了如何使用c#在asp.net中的静态方法中绑定转发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我在静态方法中遇到绑定中继器的一些问题。



i这里定义了函数。



[webmethod]

public static void SearchItemformText(String SearchVal)

{< br $>




string SearchString = txtSearch.Text.ToString();

if(txtSearch.Text!= null || txtSearch.Text!=)

{

使用(SqlConnection con = new SqlConnection(GetCoCrsLivedata))

{

使用(SqlCommand cmd = new SqlCommand(select item from item where+description ='+ SearchVal.ToString()+',con))

{

con.Open();

SqlDataReader sdr = cmd.ExecuteReader();

DataTable dtnew = new DataTable();

dtnew.Load(sdr);

if(dtnew.Rows.Count> 0)

{

//rptCustomers.DataSource = dtnew;

//rptCustomers.DataBind()//我正在


}

con.Close();

}

}

}

}< / pre>







请帮助实现这一个在静态Web方法中绑定转发器的替代解决方案。



谢谢。

Hi friends,

I am facing some problems to binding repeater in static method.

i have defined function here.

[webmethod]
public static void SearchItemformText(String SearchVal)
{


string SearchString = txtSearch.Text.ToString();
if (txtSearch.Text != null || txtSearch.Text != "")
{
using (SqlConnection con = new SqlConnection(GetCoCrsLivedata))
{
using (SqlCommand cmd = new SqlCommand("select description from item where " + "description='" + SearchVal.ToString() + "'", con))
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
DataTable dtnew = new DataTable();
dtnew.Load(sdr);
if (dtnew.Rows.Count > 0)
{
//rptCustomers.DataSource = dtnew;
//rptCustomers.DataBind()// I am getting

}
con.Close();
}
}
}
}</pre>



please help to achieve this one alternate solution to bind repeater in Static Web Method.

Thanks.

推荐答案

您无法在静态 Web方法中绑定任何服务器控件。您可以将表返回到客户端并使用 jQuery 绑定。



参考一个示例 - 在其中 [ ^ ]。
You can't bind any server control inside the static Web Method. You can return the table to client side and bind using jQuery.

Refer one example - here[^].


这篇关于如何使用c#在asp.net中的静态方法中绑定转发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆