Edit database table with LinkButton in gridview without EditItemTemplate

 Hi :

 I have have a gridview with bounded data from database "Task" , I used LinkButton to open file from folder where file name got from database .

I need too when click on Linkbutton change value in database (  to 1 ) this value used to bind image in Image field into gridview such as Email ;

in another way I need to change image value when file opened ( only when Linkbutton clicked)


I need help in this subject


abusbeih wasim

2/10/2008 9:44:45 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 35
Get it on Google Play
Get it on Apple App Store

 create a link button in the gridview. You handle the link button click event in the gridview.RowCommand event.


Please mark the answer if it helped you
2/10/2008 10:00:24 AM

I tried this but error occur in Linkbutton event

because Command_Row cannot passing the selected row index to Linkbutton event

C# code is...

protected void Update_Click(object sender, EventArgs e)


int no;

no = Convert.ToInt32(GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString());

string SQL;

SQL = "SELECT * from Task where ID=" + no.ToString();

OdbcCommand cmd = new OdbcCommand(SQL, conn);

DataSet ds = new DataSet();

OdbcDataAdapter objAdapter = new OdbcDataAdapter(SQL, conn);

objAdapter.Fill(ds, "Task");

ds.Tables[0].Rows[0]["opened"] = "1";

OdbcCommandBuilder objBuilder = new OdbcCommandBuilder(objAdapter);

objAdapter.Update(ds, "Task");


2/10/2008 12:52:29 PM


because Command_Row cannot passing the selected row index to Linkbutton event

protected void Update_Click(object sender, EventArgs e)


  LinkButton lb=sender as LinkButton;

GridViewRow gvr=lb.Parent.Parent as GridViewRow 'Hierarchy may vary in your case. You can set a breakpoint here to test and get the reference of the GridViewRow






Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
2/12/2008 3:39:59 AM

Similar Artilces:

How to add the data present in the controls to a table control without any database involvement.
Hi All,i am four controls where i will write the text and once i click the add button those should get added to the table .i want 6 columns fixed in the table and rows as many as required.i tried doing that taking a table server control and able to load the table.but the problem is whenver i am adding a new row the old one is gfetting overwritten by this and at the end i am getting only one row.  System.Web.UI.WebControls.Table t1 = new System.Web.UI.WebControls.Table();  i have declared the below one global TableRow tr; TableCell tc1; TableCell tc2; TableCell tc...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Direct editing of gridView or Ddatagrid controls without clicking on an EDIT link
I have an application where lots of data is presented to the user in a gridView control and the user needs the option to review and overwrite any values in the cells of the grid.  My users find it very annoying and time consuming to click on an edit link to turn a row of the gridView into edit mode.  Typically, they might jump around and edit a few values in several rows.  Is there any way to present the data in a gridView control, datagrid control or something that looks like a grid where the entire grid is already in edit mode?  Can you make a grid that cont...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

GridView Control Without table generation
Hi All, I have a simple question i think, i have a pageable GridView Control i i'm having some problems with the table html element that is generated by the control. Is it possible to say that i don't want any table generation with the GRIDVIEW ?   Tks in Advance PedroBernardo   i think this is possible, when you are overriding the Render mtd of page.. but how can you show the data..of gridview on the page if u r not generating tables??Thanks, Mahadeo-----------------------------------------------Best is Not the END point, but a starting point for Innovation------...

Edit GridView without template control
 I have a gridview but need to bulk edit the gridview via a event from a button.  Not sure how to go about doing that.  Any examples or ideas?   Thanks,  http://www.gridviewguy.com/ArticleDetails.aspx?articleID=219_GridView_All_Rows_in_Edit_ModeGive a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.  Yeah I tried that or something similar and could not get it to work.  When it binds back to the grid its empty and not a textbox.   can you show us the code what you tried? so that we will do necessary...

GridView editing without using data source controls?
I am binding my gridview without using a datasource control and instead doing it in the code behind. However, I would like to use the inline editing features of the gridview. Could someone please point me to an example that does gridview editing/updating 'manually' in the code behind? Thanks,Tim just create an object data source on your page and point it to a Class that acts as a BLL . in that class make public methods like: updateTHECLASS()insertTHECLASS()deleteTHECLASS() and in the object data sources insert, update, and delete methods put in those public methods you made in...

accessing item template controls of gridview without database
hi, I am having a gridview with Item Template Controls as below //////////////////////////////////////////////////////////////////////////////////////////////// '--%> 01 02 ...

GridView and Javascript
Hey All, I need help from  you. I have a GridView. In the  Edit Item template of the first Column I have a textbox, an user control and hidden field. When I click on the user control it  opens a pop up from which I can choose the required value. The text value is populated in the textbox and Id in the hidden field. Here's the code for edit template.         <EditItemTemplate>                        <table cellpaddin...

Updating multiple tables in database using one Gridview control
I have a SQL datasource which performs a join on multiple tables which is displayed through a gridview. I would like to be able to edit the columns but can't figure out how to do an update on multiple tables at once. " SelectCommand="SELECT aspnet_Users.UserName, aspnet_Membership.Email, aspnet_Roles.RoleName, aspnet_Membership.IsApproved FROM aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN aspnet_UsersInRoles ON aspnet_Membership.UserId = aspnet_UsersInRoles.UserId INNER JOIN aspnet_Roles ON aspnet_UsersInRo...

How to add a blank row into GridView Control, for editing and inserting data into database.
Dear all:      I show my data in browser with ObjectDataSource and GridView .The GridView have Edit,Select,Update functions.However ,I have an idea that: if I click some button, the GridView Control can add one blank row in its bottom where I can Edit data and Insert these data into database.I don't know whether the GridView Control  have these function.      Please give me some advise.      Thanks a lot! The GridView don't support Insert. Take a look at th...

displaying, Adding/editing database WithOUT a Datagrid/datalist control?! help please!
Hi, so far what i've seen of ASP.NET and databases is that its all to do with datagrids?! Now i don't know about you, but in regular ASP, i've never janked a bunch of records out of a database in order to just "simply" display them in a table fashion. For me it's mostly been getting 1 or more records and displaying the recordset in a form that is NOT a table.. So when i decided to make a switch from ASP to ASP.NET and i couldn't really find anything to clearly tell me how to do stuff i did before i got confused. What i'd want to do for example is to have an asp.net page...

GridView: editing without clicking edit link
Hi guys, I'd like to edit the content of the gridview without using 'edit' link. User can just click the cell and edit the data. Any links or thoughts would be appreciate.I can do it! Well, I have not tried but take a look at this: http://www.targetprocess.com/blog/2007/10/grid-inline-editing-using-aspnet-ajax.html Other than these, there are 3rd party grids which let you do MS Excel like editing. A Google search will help.Mark replies as answers if they helped you solve the problem. I don't want to pay for the control. Googled, but no luck. Any ideas?I can do it! ...

Why I cannot create/edit tables in VS.Net Server explorer for SQL Server 2000 Developer local database?
I found that when I install MSDE, then I can create/edit database objects for MSDE database in Visual Studio 2003 Server Explorer, but when I try to create/edit database objects under the default database created by the SQL Server 2000 installation, I cannot do these tasks as no option for these tasks appear when I right-click on the database object in Server Explorer.  Anyone knows why this is happening?sun21170 I reproed your issue. And I found in MSDN it is said the Server Explorer can: -Open and view Server Explorer -Add a data connection -Add a server -Drag a...

Web resources about - Edit database table with LinkButton in gridview without EditItemTemplate - asp.net.presentation-controls

Resources last updated: 12/14/2015 3:00:30 PM