Hi,
I am using RADgrid and I am using server side required field validators.
I do not want to use template columns and so can not add span tag which shows * in red color if a field id required.
I am able to show the errormessage after the validation which is fine.
But the requirement is to let user know in the begining if the field is required by showing * mark against the field.
Is there any simpler way of doing this for gridbound columns without using template column .
I am using RADgrid and I am using server side required field validators.
I do not want to use template columns and so can not add span tag which shows * in red color if a field id required.
I am able to show the errormessage after the validation which is fine.
But the requirement is to let user know in the begining if the field is required by showing * mark against the field.
Is there any simpler way of doing this for gridbound columns without using template column .
5 Answers, 1 is accepted
0
Accepted

Shinu
Top achievements
Rank 2
answered on 10 Jul 2012, 05:08 AM
Hello Prachi,
One suggestion is that you can add a label dynamically to the column in edit mode. Here is the sample code.
C#:
Thanks,
Shinu.
One suggestion is that you can add a label dynamically to the column in edit mode. Here is the sample code.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
Label lbl =
new
Label();
TextBox txt = (TextBox)item[
"ID"
].Controls[0];
lbl.Text =
"*"
;
lbl.ForeColor = System.Drawing.Color.Red;
item[
"ID"
].Controls.Add(lbl);
}
}
Thanks,
Shinu.
0

Prachi
Top achievements
Rank 1
answered on 10 Jul 2012, 05:28 AM
Hello Shinu,
Thanks for the quick reply and simple solution.
Prachi
Thanks for the quick reply and simple solution.
Prachi
0

Prachi
Top achievements
Rank 1
answered on 02 Aug 2012, 12:54 AM
HI,
I have a problem with adding label in databound.
I have few events e.g. selectedIndexChanged that calls postback.
One it calls the postback event it removes this * added from edit/create screen.
I have a problem with adding label in databound.
I have few events e.g. selectedIndexChanged that calls postback.
One it calls the postback event it removes this * added from edit/create screen.
0

Shinu
Top achievements
Rank 2
answered on 02 Aug 2012, 04:39 AM
Hello,
Try adding the label in ItemCreated event.
C#:
Thanks,
Shinu.
Try adding the label in ItemCreated event.
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
Label lbl =
new
Label();
TextBox txt = (TextBox)item[
"ID"
].Controls[0];
lbl.Text =
"*"
;
lbl.ForeColor = System.Drawing.Color.Red;
item[
"ID"
].Controls.Add(lbl);
}
}
Thanks,
Shinu.
0

Prachi
Top achievements
Rank 1
answered on 02 Aug 2012, 04:46 PM
Thanks Shinu,
It works inside :
It works inside :
if(e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
}
instead of
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
}