Hi,
I was wondering if there is a way to make a single cell readonly within
a GridView? I know you can do it for a column but what about a cell
within that column?
Thanks! 7 10368
Hello al******@gmail. com,
Sorry, missed topic a little bit (too tired after work)
Have u tried to handle CellBeginEdit and check the index of your cell in
GridViewCellCan celEventArgs to call Cancel property as described there http://msdn2.microsoft.com/en-us/library/ms993231.aspx
>http://groups.google.com/group/micro...framework.wind owsforms.contr ols/browse_frm/thread/a28d453ee51dea4 5/fdb4aa3a2b7a731 8
>>I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column?
Thats for a DataGrid (Windows not Web controls)
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Thats alright Michael, I know the feeling.
However, the article you are referring to is again for windows forms, I
believe this is for the new DataGridView class.
>
Sorry, missed topic a little bit (too tired after work)
Have u tried to handle CellBeginEdit and check the index of your cell in
GridViewCellCan celEventArgs to call Cancel property as described there http://msdn2.microsoft.com/en-us/library/ms993231.aspx http://groups.google.com/group/micro...framework.wind
owsforms.contro ls/browse_frm/thread/a28d453ee51dea4 5/fdb4aa3a2b7a731 8
I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column?
Thats for a DataGrid (Windows not Web controls)
This is what I'm trying to do, the property value DOES change, but I
feel like this isnt the correct way of doing it. There may be
something else needed missing?
Here is my RowCommand event code it will basically kick into edit mode
when a user double clicks on a row:
protected void GridView1_RowCo mmand(object sender,
GridViewCommand EventArgs e)
{
GridView _gridView = (GridView)sende r;
// Get the selected index and the command name
int _selectedIndex = int.Parse(e.Com mandArgument.To String());
string _commandName = e.CommandName;
string _eventArgument = Request.Form["__EVENTARGUMEN T"];
DataControlFiel dCell cell =
((DataControlFi eldCell)gameGri d.Rows[1].Controls[3]);
BoundField field1 = (BoundField)(ce ll.ContainingFi eld);
//field1.ItemStyl e.Width.Value = "100";
TextBox1.Text = TextBox1.Text + cell.Text;
lblStatus.Text = lblStatus.Text + field1.ReadOnly .ToString();
if (cell.Text == @" ")
{
field1.ReadOnly = false;
//cell.DataBind() ;
}
else
{
field1.ReadOnly = true;
//cell.DataBind() ;
}
lblStatus.Text = lblStatus.Text + field1.ReadOnly .ToString();
BindGrid();
switch (_commandName)
{
case ("SingleClick") :
_gridView.Selec tedIndex = _selectedIndex;
this.Message.Te xt += "Single clicked GridView row at
index " + _selectedIndex. ToString() + " on cell index " +
_eventArgument + "<br />";
break;
case ("DoubleClick") :
_gridView.EditI ndex = _selectedIndex;
_gridView.Selec tedIndex = -1;
BindGrid();
this.Message.Te xt += "Double clicked GridView row at
index " + _selectedIndex. ToString() + " on cell index " +
_eventArgument + "<br />";
break;
}
}
I tried following the ReadOnly propoerty values across post backs
initial: False
my change: True
postback: False
my change: True
postback: False
mychage: True
.....
Problem fixed...in the RowDataBound event, I check if its in edit mode,
if so, then I check to see if the cell has a value and set the ReadOnly
property based on that.
protected void GridView1_RowDa taBound(object sender,
GridViewRowEven tArgs e)
{
DataControlFiel dCell cell;
TemplateField field;
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
if (e.Row.RowState == DataControlRowS tate.Edit
|| e.Row.RowState == (DataControlRow State.Edit
| DataControlRowS tate.Alternate) )
{
GridViewRow row = e.Row;
for (int index = 1; index < 10; index++)
{
TextBox4.Text = TextBox4.Text + "\r\n" +
String.Concat(" SudokuCell", index).ToString ();
TextBox theCell =
(TextBox)row.Fi ndControl(Strin g.Concat("Sudok uCell", index));
// lblStatus2.Text = lblStatus2.Text + (theCell.Text
== @"").ToString() ;
if (theCell.Text == @"")
{
theCell.ReadOnl y = false;
//theCell.Enabled = false;
//TextBox1.Text = theCell.ToStrin g();
}
else
{
theCell.ReadOnl y = true;
//theCell.Enabled = false;
theCell.BorderS tyle = BorderStyle.Non e;
theCell.BorderW idth =
System.Web.UI.W ebControls.Unit .Pixel(0);
}
}
Hello al******@gmail. com,
Good. Bookmarked.
Tnx
Problem fixed...in the RowDataBound event, I check if its in edit
mode, if so, then I check to see if the cell has a value and set the
ReadOnly property based on that.
protected void GridView1_RowDa taBound(object sender,
GridViewRowEven tArgs e)
{
DataControlFiel dCell cell;
TemplateField field;
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
if (e.Row.RowState == DataControlRowS tate.Edit
|| e.Row.RowState == (DataControlRow State.Edit
| DataControlRowS tate.Alternate) )
{
GridViewRow row = e.Row;
for (int index = 1; index < 10; index++)
{
TextBox4.Text = TextBox4.Text + "\r\n" +
String.Concat(" SudokuCell", index).ToString ();
TextBox theCell =
(TextBox)row.Fi ndControl(Strin g.Concat("Sudok uCell", index));
// lblStatus2.Text = lblStatus2.Text +
(theCell.Text
== @"").ToString() ;
if (theCell.Text == @"")
{
theCell.ReadOnl y = false;
//theCell.Enabled = false;
//TextBox1.Text = theCell.ToStrin g();
}
else
{
theCell.ReadOnl y = true;
//theCell.Enabled = false;
theCell.BorderS tyle = BorderStyle.Non e;
theCell.BorderW idth =
System.Web.UI.W ebControls.Unit .Pixel(0);
}
}
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tfsmag |
last post by:
Hello,
I have a function that returns a dynamically created gridview. This
works fine, however it does not seem to be able to maintain state when
adding sorting or paging to the gridview. Does anyone have any idea how
to get this to work? below is the code. Please bear in mind that the
function is actually located in a seperate class file...
|
by: NH |
last post by:
I have a girdview with paging enabled. How can I add a message in the footer
to say "Viewing records 1-15 of 45" etc
Thanks
|
by: Mike P |
last post by:
When you use a SqlDataSource to hook up data to a GridView it seems to
be to be very inflexible. For example, I want to create my own Delete
button with my own code and I also want to create a popup warning for
the user before delete takes place. Whenever I do this with a
SqlDataSource, I get the error 'Deleting is not supported by data...
|
by: den 2005 |
last post by:
Hi everybody,
I created a Gridview with a TemplateField and there is Label control in
ItemTemplate and a DropdownList control in EditItemTemplate, I was to
displayed them ok when I click the Edit Command button. But when I about to
get the value of this template field I get an empty string value. I check the
following the local dtFiles has...
|
by: Evan M. |
last post by:
Here's my GridView and my SqlDataSource
<asp:GridView ID="ContactHistoryGrid" runat="server"
AutoGenerateColumns="False" DataSourceID="ContactHistoryDS"
DataKeyNames="JobHistoryID"
OnRowCreated="ContactHistoryGrid_RowCreated"
CssClass="GridViewTable"
GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True"
AllowPaging="True">...
| |
by: pargat.singh |
last post by:
Hi Everyone:
I have a gridview control with AllowSorting="True" and work ok.
But my page will be used by different user from different region so i
need to change the HeaderText based on language like english or french
etc.When i updat ethe header on GridView1_RowCreated sorting does not
work anymore. Below are my code. Is this because of...
|
by: pargat.singh |
last post by:
Hi:
I am using a grid and having a problem with sorting. Below are my
code and change the header name at run time as below based on
language.If i don't change the header name it work. Can someone please
help me so that i can enable the sorting and change the header as
well. Thanks, in advance.
<asp:GridView ID="GridView1"...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in a
particular cell, gridline disappaers around that cell.I want the grid lines
to appear all the time even if the cell is empty. Can anyone tell me what am
I doing wrong. Below is my...
|
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= |
last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works
very well.
however, i tried to translate it to c# and i'm getting the header inserting
itself over the first datarows and inserting blank rows at the bottom.
i can post the code if necessary for the C# but it basicly mirrors the vb.net
--
(i''ll be asking a lot...
|
by: mghihor |
last post by:
Dear GridView Experts!
I have problems with GridView when adding a column using TemplateField.
I fill GridView1 from a stored procedure. It has a Select statement and returns 14 columns, AutoGenerateColumns="True".
When I add two columns manually to be able to start drag and drop, the drag and drop works OK, but in GridView1_PreRender() and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |