本文介绍了DataSource和DataSourceID都在'GridView1'上定义。删除一个定义。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有



出现此错误。



我试图将undernoted更改为GridView1 .DataSourceID =

Dear All

Having this error coming.

I tried to change the undernoted to GridView1.DataSourceID =

dsas

but it gave an error.

I also tried to change

<pre> AutoGenerateColumns="False" BackColor="#FFFFCC" DataSourceID="SqlDataSource1" 

to <pre> AutoGenerateColumns="False" BackColor="#FFFFCC" DataSource="SqlDataSource1" 

and it also was no ok.

What  do I do to resolve this issue?

*************************************
<pre> <td class="style32" colspan="8">
                <div style="height: 80px; text-align: left;" align="center">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" BackColor="#FFFFCC" DataSourceID="SqlDataSource1" 
                        Font-Overline="False" Font-Size="X-Small" ForeColor="Black" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" PageSize="5" 
                        style="margin-right: 91px" Width="918px">





************************ ***************

public void LoadSearch()

{





尝试

{

SqlConnection connect = new SqlConnection();

connect.ConnectionString = ConfigurationManager .ConnectionStrings [ApplicationServices]。ConnectionString;

connect.Open();

SqlDataAdapter da = new SqlDataAdapter(SELECT *通过ID_CODE从LOANS订购,连接;



SqlCommand SqlCmd = new SqlCommand(sp_searchActLoan,connect);

SqlCmd.CommandType = CommandType.StoredProcedure;



SqlCmd.Parameters.AddWithValue(@ searchString,txt_Search.Text);

SqlCmd.ExecuteNonQuery() ;



SqlDataAdapter daa = new SqlDataAdapter();

daa.SelectCommand = SqlCmd;



DataSet dsas = new DataSet();

daa.Fill(dsas,searchResults);

GridView1.DataSource = dsas;

//GridView1.DataSourceID = null;

GridView1.DataSource = dsas;

GridView1.DataBind();

connect。关闭();





---------------------- ------------------- -

----------------------------------------- -



***************************************
public void LoadSearch()
{


try
{
SqlConnection connect = new SqlConnection();
connect.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
connect.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LOANS order by ID_CODE", connect);

SqlCommand SqlCmd = new SqlCommand("sp_searchActLoan", connect);
SqlCmd.CommandType = CommandType.StoredProcedure;

SqlCmd.Parameters.AddWithValue("@searchString", txt_Search.Text);
SqlCmd.ExecuteNonQuery();

SqlDataAdapter daa = new SqlDataAdapter();
daa.SelectCommand = SqlCmd;

DataSet dsas = new DataSet();
daa.Fill(dsas, "searchResults");
GridView1.DataSource = dsas;
//GridView1.DataSourceID = null;
GridView1.DataSource = dsas;
GridView1.DataBind();
connect.Close();


------------------------------------------
------------------------------------------

推荐答案

DataSourceID="SqlDataSource1"




GridView1.DataSource = dsas;



GridView无法决定将哪个用于数据呈现。你必须选择!!!删除其中一个......


The GridView can't decide which to use for data rendering. You have to choose!!! Remove one of them...


这篇关于DataSource和DataSourceID都在'GridView1'上定义。删除一个定义。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 00:57