New to using the Radgrid and trying to learn my way around but I found that I am stuck and need some help.
I have a small web app that allows the user to import a *.csv file that I bind to a RadGrid. I want the user to have the ability to add, edit or delete rows before storing to a table. I've got everything working except adding data.
For the edit (RadGrid.UpdateCommand) I am able to get the Item Index, cast as a GridEditableItem, specify the column name, cast as a textbox and get the text value.
When I try to do this for the add record row, which has an Item Index of -1, I get an error "Index was out of range. Must be non-negative and less than the size of the collection."
I have also tried using the unique ID from the sender and concatenating that with the column number to get the unique ID for the individual textbox (which I have verified using Google Chrome dev tools) but get an "Object reference not set to an instance of an object" error.
So I'm stuck. I'm sure there is a better way to do this but I'm not familiar enough with RadGrid yet to know how.
Any help is appreciated. Thanks.
I have a small web app that allows the user to import a *.csv file that I bind to a RadGrid. I want the user to have the ability to add, edit or delete rows before storing to a table. I've got everything working except adding data.
For the edit (RadGrid.UpdateCommand) I am able to get the Item Index, cast as a GridEditableItem, specify the column name, cast as a textbox and get the text value.
Dim
editItem
As
GridEditableItem =
CType
(gvMSR.EditItems(e.Item.ItemIndex), GridEditableItem)
dtb.Rows(e.Item.ItemIndex).Item(
"column1"
) =
CType
(editItem(
"column1"
).Controls(0), TextBox).Text
When I try to do this for the add record row, which has an Item Index of -1, I get an error "Index was out of range. Must be non-negative and less than the size of the collection."
I have also tried using the unique ID from the sender and concatenating that with the column number to get the unique ID for the individual textbox (which I have verified using Google Chrome dev tools) but get an "Object reference not set to an instance of an object" error.
Dim
itemPrefix
As
String
= e.Item.UniqueID.ToString &
"$ctl"
dtb.Item(
"column1"
) =
CType
(e.Item.FindControl(itemPrefix &
"00"
), TextBox).Text
So I'm stuck. I'm sure there is a better way to do this but I'm not familiar enough with RadGrid yet to know how.
Any help is appreciated. Thanks.