Today, when my colleague asked me a question about the gridview
He wants to add an attribute to textbox in the edit state.
At the beginning, it was always alternating rows, but normal rows were always allowed.
It took only half a day to know that it was the time of switching lines and editing.
Write as follows:
Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
{
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
If (E. Row. rowstate = datacontrolrowstate. Edit | (E. Row. rowstate = (datacontrolrowstate. Edit | datacontrolrowstate. Alternate )))
{
Textbox TB = (textbox) E. Row. findcontrol ("textbox2 ");
String clientid = Tb. clientid;
TB. Attributes. Add ("onclick", "FNA ('" + clientid + "')");
}
}
}
The previous code was written in this way.
Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
{
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
If (E. Row. rowstate = datacontrolrowstate. Edit |
{
Textbox TB = (textbox) E. Row. findcontrol ("textbox2 ");
String clientid = Tb. clientid;
TB. Attributes. Add ("onclick", "FNA ('" + clientid + "')");
}
}
}