5 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 19 Jan 2011, 12:52 PM
Hello,
You'd need to use the CellFormatting event. For exmaple:
You can find out more about CellFormatting here.
If there is anything else, please let me know
thanks
Richard
You'd need to use the CellFormatting event. For exmaple:
this
.radGridView1.CellFormatting +=
new
Telerik.WinControls.UI.CellFormattingEventHandler(
this
.radGridView1_CellFormatting);
private
void
radGridView1_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement !=
null
)
{
if
(e.CellElement.Text ==
""
)
{
e.CellElement.Text =
"Updated"
;
}
}
}
You can find out more about CellFormatting here.
If there is anything else, please let me know
thanks
Richard
0
Somnath
Top achievements
Rank 1
answered on 19 Jan 2011, 01:34 PM
Hello,
With this code , the radgridview colums which has datasource also changed with
"Updated", Can you show how to avoid this.........
And
How to fire this radGridView1_CellFormatting event only when adding new row
in the radgridview...?
Thank
With this code , the radgridview colums which has datasource also changed with
"Updated", Can you show how to avoid this.........
And
How to fire this radGridView1_CellFormatting event only when adding new row
in the radgridview...?
Thank
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 19 Jan 2011, 01:42 PM
Hello,
In this case, instead of using CellFormatting, you can use the UserAddingRow event. This way you can target the new row only and also add a tag which will allow you to inspect it later when updating your data source to see if you want to use the value or not.
E.g.
Hope that helps
Richard
In this case, instead of using CellFormatting, you can use the UserAddingRow event. This way you can target the new row only and also add a tag which will allow you to inspect it later when updating your data source to see if you want to use the value or not.
E.g.
this
.radGridView1.UserAddingRow +=
new
Telerik.WinControls.UI.GridViewRowCancelEventHandler(
this
.radGridView1_UserAddingRow);
private
void
radGridView1_UserAddingRow(
object
sender, GridViewRowCancelEventArgs e)
{
if
(e.Rows[0].Cells[
"Name"
].Value ==
null
)
{
e.Rows[0].Cells[
"Name"
].Value =
"DefaultValue"
;
e.Rows[0].Cells[
"Name"
].Tag =
true
;
}
}
Hope that helps
Richard
0
Somnath
Top achievements
Rank 1
answered on 19 Jan 2011, 02:36 PM
Hello,
Using the code provided by you,I get a Error--
"Input string was not in a correct format"
at this line--
Using the code provided by you,I get a Error--
"Input string was not in a correct format"
at this line--
e.Rows[0].Cells[1
].Value =
"DefaultValue"
;
Actually, this cells column belongs to GridViewComboBoxColumn..
Can you come with updated code..?
Thanks..
0
Richard Slade
Top achievements
Rank 2
answered on 19 Jan 2011, 02:38 PM
Hello,
In that case, set the value to whichever you want your default value to be. Otherwise, you could change the drop down in the AddNewRow section to be a DropDownList so that there is always a value selected.
Hope that helps
Richard
In that case, set the value to whichever you want your default value to be. Otherwise, you could change the drop down in the AddNewRow section to be a DropDownList so that there is always a value selected.
Hope that helps
Richard