Overload takes 4 arguments Error [Resolved]

Posted by Self-Innovator under ASP.NET on 4/11/2012 | Points: 10 | Views : 1454 | Status : [Member] | Replies : 16
Hi...pls solve this error

List<Publisher> collectionOfPub = new List<Publisher>();
collectionOfPub.Add(new Publisher("Ram", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Kabir", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Harris", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Ali", "IPL tech Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Kapoor", "ITPL Bangalore", "INDIA", "SSS"));
this.gvpub.DataSource = collectionOfPub;
this.gvpub.DataBind();
//Error 1 No overload for method 'Publisher' takes '4' arguments

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
use this code. this is very simple, there are so many ways to solve this issue, you can create a custom table or you can create properties in class and set it in list type.

Using system.Data;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable("Publisher");
dt.Columns.Add(new DataColumn("Name"));
dt.Columns.Add(new DataColumn("Address1"));
dt.Columns.Add(new DataColumn("Address2"));
dt.Columns.Add(new DataColumn("Company"));

DataRow dr = dt.NewRow();
dr["Name"] = "Ram";
dr["Address1"] = "Tidel Park Chennai";
dr["Address2"] = "UAE";
dr["Company"] = "SSS";

dt.Rows.Add(dr);
this.gvpub.DataSource = dt;
this.gvpub.DataBind();

}
}


Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: arun_ymail-14946 on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
can you post the Publisher class..

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi arun..
this is my .aspx Grid where i am binnding values statically while page load
 <Columns>

<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox runat="server" ID="chkAll" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelection" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Address1" HeaderText="Address1" />
<asp:BoundField DataField="Address2" HeaderText="Country" />
<asp:BoundField DataField="Company" HeaderText="Company" />
</Columns>


Here on Page load i am adding the values as a collection of publsher...which prevsly i send the code...Pls findsoln

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: arun_ymail-14946 on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Binding code pls..

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Binding code and explain briefly plz....


Thanks & Regards
Hari

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Pls go through this...Whole Code I am getting Error Over load take 4 arguments ...
<asp:GridView ID="gvpub" runat="server" AutoGenerateColumns="False">

<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox runat="server" ID="chkAll" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelection" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Address1" HeaderText="Address1" />
<asp:BoundField DataField="Address2" HeaderText="Country" />
<asp:BoundField DataField="Company" HeaderText="Company" />
</Columns>
</asp:GridView>

.cs
 protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
List<Publisher> collectionOfPub = new List<Publisher>();
collectionOfPub.Add(new Publisher("Ram", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Kabir", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Harris", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Ali", "IPL tech Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new Publisher("Kapoor", "ITPL Bangalore", "INDIA", "SSS"));
this.gvpub.DataSource = collectionOfPub;
this.gvpub.DataBind();

}

}


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: arun_ymail-14946 on: 4/11/2012 [Member] Starter | Points: 25

Up
0
Down
Can you post the publisher class code..

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Arun i dont use any Userdefined publisher class code...
In Page load Event itself i am using a publisher class code...Pls go through the whole code S there any mistake....

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Publisher class will take only one argument of type System.Security.Cryptography.X509Certificates.X509Certificate
You can not give more than one argument for publisher class, because there is no constructor for that.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi rajini ...
Will u pls find me the Soln For my above Code ie:Publisher i wanted to add values statically in my GridVw

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,
May i know, why you are using publisher? is there any reason? you can also bind your grid by using LIST<customeClass> only.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
use following code

public class MyClass

{
string strPub_Name;
string strPub_Address1;
string strPub_Address2;
string strPub_Comp;
public MyClass(string Name, string Address1, string Address2, string Company)
{
this.strPub_Name = Name;
this.strPub_Address1 = Address1;
this.strPub_Address2 = Address2;
this.strPub_Comp = Company;
}
}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

List<MyClass> collectionOfPub = new List<MyClass>();
collectionOfPub.Add(new MyClass("Ram", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Kabir", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Harris", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Ali", "IPL tech Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Kapoor", "ITPL Bangalore", "INDIA", "SSS"));
this.GridView1.DataSource = collectionOfPub;
this.GridView1.DataBind();
}
}


Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
hi rajini,
S the publisher is just a like userDefined Variable name....i've declared...pls solve the issue pls go thru my code Once more and find soln...

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
S thanx Rajini...Solved

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Another way to do this use a class and define property.
You can use this also,

protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack){
List<MyClass> collectionOfPub = new List<MyClass>();
collectionOfPub.Add(new MyClass("Ram", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Kabir", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Harris", "Tidel Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Ali", "IPL tech Park Chennai", "UAE", "SSS"));
collectionOfPub.Add(new MyClass("Kapoor", "ITPL Bangalore", "INDIA", "SSS"));

this.gvpub.DataSource = collectionOfPub;
this.gvpub.DataBind();
}
}
public class MyClass
{
string _PubName;
string _PubAddress1;
string _PubAddress2;
string _PubComp;

public MyClass(string Name, string Address1, string Address2, string Company)
{
_PubName = Name;
_PubAddress1 = Address1;
_PubAddress2 = Address2;
_PubComp = Company;
}

public string Name
{
get { return _PubName; }
set { _PubName = value; }
}

public string Address1
{
get { return _PubAddress1; }
set { _PubAddress1 = value; }
}
public string Address2
{
get { return _PubAddress2; }
set { _PubAddress2 = value; }
}
public string Company
{
get { return _PubComp; }
set { _PubComp = value; }
}

}


This is tested code, you can do like that.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Great.... Mark as answer if it helped you.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response