C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




I am Editing the row in datagrid. After the row updation the data is like System.Web.UI.LiteralContr


Posted Date: 24 May 2007      Total Responses: 7

Posted By: kamal kumar das       Member Level: Gold     Points: 2


I am Editing the row in datagrid. After the row updation the data is like System.Web.UI.LiteralControl.
Whats the problem ?




Responses

Author: victoria    24 May 2007Member Level: GoldRating:     Points: 2
can u put on the code here???




Author: kamal kumar das    24 May 2007Member Level: GoldRating:     Points: 2
TextBox tbox = new TextBox();
string details,Id;

tbox.Text = (e.Item.Cells[3].Controls[0].ToString());
details = tbox.Text;

Id = dgAllergies.DataKeys[e.Item.ItemIndex].ToString();

string sql = "UPDATE PatientAllergies SET details='"+details+"',RecordModified = '"+System.DateTime.Now+"' WHERE id='"+Id+"'";
con = new SqlConnection(strConnection);
com = new SqlCommand(sql,con);
con.Open();
com.ExecuteNonQuery();
dgAllergies.EditItemIndex = -1;
dgAllergies.DataBind();
con.Close();


Author: victoria    24 May 2007Member Level: GoldRating:     Points: 2
TextBox tbox = new TextBox();
tbox.Text = (e.Item.Cells[3].Controls[0].ToString());
textbox tnum=new textbox();
tnum.Text = e.Items.cells[0].Text;
string sql = "UPDATE PatientAllergies SET details='"+tbox.text+"',RecordModified = '"+System.DateTime.Now+"' WHERE id='"+tnum.Text+"'";
con = new SqlConnection(strConnection);
com = new SqlCommand(sql,con);
con.Open();
com.ExecuteNonQuery();
con.close();
dgAllergies.EditItemIndex = -1;
com.commandtext="select *from patientallergies";
con.open();
dgallergies.datasource=com.executereader();
dgallergies.databind();
con.Close();


Author: kamal kumar das    24 May 2007Member Level: GoldRating:     Points: 2
Thanks but It is still giving same result.


Author: kamal kumar das    24 May 2007Member Level: GoldRating:     Points: 2
Thanks but It is still giving same result.


Author: kamal kumar das    24 May 2007Member Level: GoldRating:     Points: 2
Thanks but It is still giving same result.


Author: victoria    24 May 2007Member Level: GoldRating:     Points: 2
let me expalin you clearly...

1.first of all need to add edit,update,cancel button column using property builder..
2.if you want create bound columns...
3.then
check what is placement of id in the datagrid..say here it is 0th column and name 1st,remarks 2nd and address 3rd column ..ok

then
add the following code to editcommand..

datagrid1.edititemindex=e.item.itemindex;
bind();

then
add the following code to updatecommand..

textbox tname=(textbox)e.item.cells[1].controls[0];
textbox trem=(textbox)e.item.cells[2].controls[0];
textbox tadd=(textbox)e.item.cells[3].controls[0];
textbox tnum=new textbox();
tnum.Text=e.item.cells[0].text

string s="update tablename set name='"+tname.textt+"',remarks='"+trem.text+"',address='"+tadd.text+"' where id='"+tnum.text+"'";

then normal execution
cmd=new sqlcommand(s,con);
con.open();
cmd.executenonquery();
con.close();
datagrid1.edititemindex=-1;
bind();


thats it

this will surely work ok apply this to your application





Post Reply
You must Sign In to post a response.
Next : I am deleting the row in datagrid.row deletion is working one I first click that is data is deleted
Previous : for every time at program execution all textboxes should be clear,how can i do it?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use