Home All Groups Group Topic Archive Search About

Making a GridView Cell read-only

Author
27 Nov 2006 5:08 PM
aljamala
Hi,

I am trying to make a Sudoku web application.  I am creating a dataset
which holds the numbers that belong to each cell.  Then these numbers
are unmasked to display the problem set to the user in a GridView.
However, I was to be able to mark the empty columns for editing.  I
have tried this but it hasn't worked so far...


protected void gameGrid_RowDataBound(object sender,
GridViewRowEventArgs e)
        {
            if (e.Row.DataItemIndex > -1)
            {
               object obj = (object)e.Row.DataItem;
                DataControlFieldCell cell =
(DataControlFieldCell)e.Row.Controls[0];
                if (cell.Text == "")
                {
                    BoundField field1 =
(BoundField)cell.ContainingField;
                    field1.ReadOnly = false;

                    //gameGrid.DataBind();
                }
            }
        }

Any ideas?  Thanks!

Author
19 Dec 2006 5:06 AM
Michael Tkachev
Hi

I recommend you to use the XSLT for that. It's easier than datagrid. Because
you can put into the XSL some logic and there you can define which the cell
must be read only...

If you have any questions, email me... :)

Sincerely yours,
Michael B. Tkachev.
m_tkac***@hotmail.com

<aljam***@gmail.com> wrote in message
Show quoteHide quote
news:1164647282.922869.82500@f16g2000cwb.googlegroups.com...
> Hi,
>
> I am trying to make a Sudoku web application.  I am creating a dataset
> which holds the numbers that belong to each cell.  Then these numbers
> are unmasked to display the problem set to the user in a GridView.
> However, I was to be able to mark the empty columns for editing.  I
> have tried this but it hasn't worked so far...
>
>
> protected void gameGrid_RowDataBound(object sender,
> GridViewRowEventArgs e)
>        {
>            if (e.Row.DataItemIndex > -1)
>            {
>               object obj = (object)e.Row.DataItem;
>                DataControlFieldCell cell =
> (DataControlFieldCell)e.Row.Controls[0];
>                if (cell.Text == "")
>                {
>                    BoundField field1 =
> (BoundField)cell.ContainingField;
>                    field1.ReadOnly = false;
>
>                    //gameGrid.DataBind();
>                }
>            }
>        }
>
> Any ideas?  Thanks!
>