I have a radgrid. I Want to let the users only create 10 rows. I have done the below in Item command event. However everytime the count is setting to 0.
public int i = 0;
protected void radgrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
if (i < 10)
{
i++;
}
else
{
e.Canceled = true;
radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None;
}
}
}
venkatzeus
Participant
1638 Points
1041 Posts
setting the number of rows in grid to 10
Dec 14, 2012 11:45 AM|LINK
Hi,
I have a radgrid. I Want to let the users only create 10 rows. I have done the below in Item command event. However everytime the count is setting to 0.
public int i = 0; protected void radgrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { if (i < 10) { i++; } else { e.Canceled = true; radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; } } }How to fix this?
Thanks
anuj_koundal
Contributor
2267 Points
540 Posts
Re: setting the number of rows in grid to 10
Dec 14, 2012 11:52 AM|LINK
Take your value in hiddenfield and then increment or apply any condition.
Anuj Koundal
My Blog
Mark as Answer on the post that helps you.
gregaDro
Member
318 Points
65 Posts
Re: setting the number of rows in grid to 10
Dec 14, 2012 11:54 AM|LINK
Hi,
Try it this way ...
protected void radgrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { if (radgrid1.Rows.Count > 10) { e.Canceled = true; radgrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; } } }venkatzeus
Participant
1638 Points
1041 Posts
Re: setting the number of rows in grid to 10
Dec 14, 2012 12:01 PM|LINK
Hi,
I am not getting the Rows Property.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: setting the number of rows in grid to 10
Dec 15, 2012 12:58 AM|LINK
What's radGrid?
What exception have you got?
markfitzme
All-Star
15349 Points
2361 Posts
Re: setting the number of rows in grid to 10
Dec 15, 2012 02:26 AM|LINK
I believe it's the Items property of RadGrid that will give you the item collection and not rows.
You will have far better luck though over at the Telerik forums. They are exceptionally active and the support their is just incredible.