473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Editable/Uneditable Gridview rows on condition

Is it possible to make an editable gridview so that certain rows are
editable and other are not editable, dependent upon a value in one of
the rows columns?
*** Sent via Developersdex http://www.developersdex.com ***
Jun 6 '06 #1
3 2129
You can try handling the click event on client side and verify the
conditions. You can return "false" from that event handler to cancel
postback.

"Mike P" <mi*******@gmail.com> wrote in message
news:ez****************@TK2MSFTNGP02.phx.gbl...
Is it possible to make an editable gridview so that certain rows are
editable and other are not editable, dependent upon a value in one of
the rows columns?
*** Sent via Developersdex http://www.developersdex.com ***

Jun 6 '06 #2
On Tue, 06 Jun 2006 08:08:01 -0700, Mike P <mi*******@gmail.com>
wrote:
Is it possible to make an editable gridview so that certain rows are
editable and other are not editable, dependent upon a value in one of
the rows columns?
*** Sent via Developersdex http://www.developersdex.com ***


I would suggest converting the command to a template so you can access
the link button. Then in your rowcreated event do something like
this.

protected void GridView1_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int id = (int) DataBinder.Eval(e.Row.DataItem, "id");
if (id > 1)
{
LinkButton lb = (LinkButton)
e.Row.FindControl("LinkButton1");
lb.Visible = false;
}
}
}
Peter Kellner
http://peterkellner.net
Jun 6 '06 #3
On Tue, 06 Jun 2006 08:08:01 -0700, Mike P <mi*******@gmail.com>
wrote:
Is it possible to make an editable gridview so that certain rows are
editable and other are not editable, dependent upon a value in one of
the rows columns?
*** Sent via Developersdex http://www.developersdex.com ***


Make sure you change the command row to a template first. Then this
code will do the trick:
protected void GridView1_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

if (e.Row.RowIndex == 0)
{
LinkButton lb = (LinkButton)
e.Row.FindControl("LinkButton1");
lb.Text = "newtextbutton";
}
}
}
Peter Kellner
http://peterkellner.net
Jun 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: laura | last post by:
Can anyone help me to decide the best way to do this please. I'm writing an intranet and I need to put something like a non-editable scrolling text box on the home page where daily announcements...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
0
by: SDRoy | last post by:
Hi Can someone help me to figure out how to get the editable textbox value from GridView in my code-behind ? I am using the code something like- GridView2.Rows.Cells.Text.Trim(). But when I...
0
by: Frank | last post by:
Hello All, I am working with VS.NET 2005 and I have an editable GridView whose HTML markup is shown below. In short, when the user clicks on the Edit button, one of the textboxes is replaced...
0
by: Christian Schlemmer | last post by:
hi, in a DetailsView i have a image display. images i want to store in a seperate directory, but it a path is added to Bind update and delete is not working. just Bind makes my...
5
by: rcoco | last post by:
Hi, I'm working on a asp.net project with a datagrid. I want the user to be adding data into Sql database using the datagrid. So I'm using a ListBox to do this and edit update and delete. I placed...
4
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
9
by: JohnShell | last post by:
Hi, I created an ASP.NET 4 columns gridview programmatically using VB.NET. The first two columns are bound to checkboxes and a database. When the user selects one or more checkboxes the database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.