Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 17, 2007 12:39 AM by vinz
All-Star
128446 Points
18142 Posts
MVP
Dec 14, 2007 12:20 AM|LINK
Good to hear that.. Regarding Datakeys then you can read on this articles below
http://www.codeproject.com/KB/webforms/GridViewConfirmDelete.aspx?df=100&forumid=254626&exp=0&select=1848451
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys.aspx
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeynames(VS.80).aspx
Member
368 Points
764 Posts
Dec 14, 2007 10:29 AM|LINK
Hi, i try to update using class below find the code
error message is cannot convert from 'method group' to 'int'
first arugement is int type that is GridView1.DataKeys[e.RowIndex].Values[0].ToString
CUSTOMER.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString ,txtName.Text, cmbGender.SelectedValue, txtCity.Text, cmbType.SelectedValue);
Contributor
5324 Points
1041 Posts
Dec 14, 2007 11:49 AM|LINK
Hi,
try the below one....
CUSTOMER.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString() ,txtName.Text, cmbGender.SelectedValue, txtCity.Text, cmbType.SelectedValue);
Dec 15, 2007 03:58 AM|LINK
Hi vinz,
i try to update in the girdview but its shows the follwing error message
ERROR MESSAGE1 - The best overloaded method match for 'Customercls.Update(int, string, string, string, string, string)' has some invalid arguments
ERROR MESSGE2- Error 2 Argument '1': cannot convert from 'string' to 'int'
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName"); DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender"); TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity"); TextBox txtState = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtState"); DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType"); customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);----- ERROR SHOWS IN THIS LINE GridView1.EditIndex = -1; FillCustomerInGrid(); }
Dec 15, 2007 04:02 AM|LINK
Hi kannan,
post customer.Update() methods signature......
Dec 15, 2007 06:14 AM|LINK
Hi vasanth,
pls look the signature
my table structure is
table name is cutomer fileds
customercode is int type
1)customercode type is int 2) customername type is string 3) gender 4) city 5) state 6) customertype
public void Update(int CustomerCode, string CustomerName, string Gender, string City, string State, string CustomerType) { // Write your own Update statement blocks. }
Dec 15, 2007 06:24 AM|LINK
customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
here you are passing string value to integer type.....
customer.Update(Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
Dec 17, 2007 12:39 AM|LINK
Hi Kannan,
Since you are assigning an INT value to your Customercodes then you should have to convert it to int...
Try this below
int code = (int)GridView1.DataKeys[e.RowIndex].Values[0]; // OR int code = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0]);
customer.Update(code, txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
vinz
All-Star
128446 Points
18142 Posts
MVP
Re: girdview insert,update,delete in c# using code
Dec 14, 2007 12:20 AM|LINK
Good to hear that.. Regarding Datakeys then you can read on this articles below
http://www.codeproject.com/KB/webforms/GridViewConfirmDelete.aspx?df=100&forumid=254626&exp=0&select=1848451
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys.aspx
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeynames(VS.80).aspx
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
Kannandesika...
Member
368 Points
764 Posts
Re: girdview insert,update,delete in c# using code
Dec 14, 2007 10:29 AM|LINK
Hi, i try to update using class below find the code
error message is cannot convert from 'method group' to 'int'
first arugement is int type that is GridView1.DataKeys[e.RowIndex].Values[0].ToString
CUSTOMER.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString ,txtName.Text, cmbGender.SelectedValue, txtCity.Text, cmbType.SelectedValue);
Kannandesikan
vasanth.kuma...
Contributor
5324 Points
1041 Posts
Re: girdview insert,update,delete in c# using code
Dec 14, 2007 11:49 AM|LINK
Hi,
try the below one....
CUSTOMER.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString() ,txtName.Text, cmbGender.SelectedValue, txtCity.Text, cmbType.SelectedValue);
Software Engineer.
Kannandesika...
Member
368 Points
764 Posts
Re: girdview insert,update,delete in c# using code
Dec 15, 2007 03:58 AM|LINK
Hi vinz,
i try to update in the girdview but its shows the follwing error message
ERROR MESSAGE1 - The best overloaded method match for 'Customercls.Update(int, string, string, string, string, string)' has some invalid arguments
ERROR MESSGE2- Error 2 Argument '1': cannot convert from 'string' to 'int'
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender");
TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity");
TextBox txtState = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtState");
DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType");
customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);----- ERROR SHOWS IN THIS LINE
GridView1.EditIndex = -1;
FillCustomerInGrid();
}
Kannandesikan
vasanth.kuma...
Contributor
5324 Points
1041 Posts
Re: girdview insert,update,delete in c# using code
Dec 15, 2007 04:02 AM|LINK
Hi kannan,
post customer.Update() methods signature......
Software Engineer.
Kannandesika...
Member
368 Points
764 Posts
Re: girdview insert,update,delete in c# using code
Dec 15, 2007 06:14 AM|LINK
Hi vasanth,
pls look the signature
my table structure is
table name is cutomer fileds
customercode is int type
1)customercode type is int 2) customername type is string 3) gender 4) city 5) state 6) customertype
public void Update(int CustomerCode, string CustomerName, string Gender, string City, string State, string CustomerType)
{
// Write your own Update statement blocks.
}
Kannandesikan
vasanth.kuma...
Contributor
5324 Points
1041 Posts
Re: girdview insert,update,delete in c# using code
Dec 15, 2007 06:24 AM|LINK
Hi kannan,
customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
here you are passing string value to integer type.....
try the below one....
customer.Update(Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]), txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
Software Engineer.
vinz
All-Star
128446 Points
18142 Posts
MVP
Re: girdview insert,update,delete in c# using code
Dec 17, 2007 12:39 AM|LINK
Hi Kannan,
Since you are assigning an INT value to your Customercodes then you should have to convert it to int...
Try this below
int code = (int)GridView1.DataKeys[e.RowIndex].Values[0]; // OR int code = int.Parse(GridView1.DataKeys[e.RowIndex].Values[0]);
customer.Update(code, txtName.Text, cmbGender.SelectedValue, txtCity.Text, txtState.Text, cmbType.SelectedValue);
MessageBox Controls for WebForms | Blog | Twitter | Linkedin