By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,302 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,302 IT Pros & Developers. It's quick & easy.

Grid View, programmatically set gridview textbox property readonly=false

P: 74
Hi

Someone please help me


string typ;
if (e.Row.RowType == DataControlRowType.DataRow)
{
typ = e.Row.Cells[4].Text;




I got this line in onRowDataBound


I have a problem, WHEN I SET THIS boundfield -> column 4, as Visible =true (to display in gridview), i can get th value by above code line.

If i set visible =false (which I don't want display in gridview), i cant get the value.
May 5 '07 #1
Share this Question
Share on Google+
2 Replies


P: 74
Hi,


Currently i have a GridView with 1 text box template column, on start, i will set this textbox readonly =true

When user click edit button, i would like to set the textbox control readonly=false so user can type in new text,

i put it in gridview1_onDataBound()

as follow

if (e.Row.RowState == DataControlRowState.Edit)
{

TextBox msgtxtBox1 = (TextBox)e.Row.FindControl("txtbox1");
msgtxtBox1.ReadOnly = false;
}


well, it is work,

when i click edit in first row of the grid, the textbox readonly set to false, i can type in new text.

BUT it is very weird, because ONLY ODD NUMBER grid row can work,

when i click on second row edit button, the textbox readonly still true,

when i click on third, it is work, then when i click on 5th row, it work too..


someone can help?
May 6 '07 #2

100+
P: 304
Hi,


Currently i have a GridView with 1 text box template column, on start, i will set this textbox readonly =true

When user click edit button, i would like to set the textbox control readonly=false so user can type in new text,

i put it in gridview1_onDataBound()

as follow

if (e.Row.RowState == DataControlRowState.Edit)
{

TextBox msgtxtBox1 = (TextBox)e.Row.FindControl("txtbox1");
msgtxtBox1.ReadOnly = false;
}


well, it is work,

when i click edit in first row of the grid, the textbox readonly set to false, i can type in new text.

BUT it is very weird, because ONLY ODD NUMBER grid row can work,

when i click on second row edit button, the textbox readonly still true,

when i click on third, it is work, then when i click on 5th row, it work too..


someone can help?
try peforming the operations in rowcommand of the gridview.
not sure as to why odd number ones work!!!
May 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.