I have a data bound grid.
With adding and deleting rows turned on.
I need to be able to add or delete a record on the grid from a add or delete button that is NOT on the grid.
For adding a row from a button ouside the grid. I m using infragistics wed image button. you can use normal asp button also.
<igtxt:WebImageButton ID="btnAddItem" runat="server" CausesValidation="False" Text="New Item" ToolTip="Add new Item" AutoSubmit="false"> <Appearance> <Image Url="./Images/img_add.png" /> <ButtonStyle Cursor="Hand" Font-Names="Arial" Font-Size="8pt"> </ButtonStyle> </Appearance> <RoundedCorners RenderingType="Disabled" /> <HoverAppearance> <ButtonStyle Font-Underline="True"> </ButtonStyle> </HoverAppearance> <Alignments VerticalImage="Bottom" /> <ClientSideEvents Click="AddRow" /> </igtxt:WebImageButton>
I am adding a row to the grid and setting the value of the two column in the grid.
function AddRow(oButton, oEvent) { igtbl_addNew("dgGrid", 0); var grid = igtbl_getGridById("dgGrid"); var activeRow = grid.getActiveRow(); activeRow.getCellFromKey("Col1").setValue(0); activeRow.getCellFromKey("col2").setValue("ABC TEXT"); activeRow.endEditRow();
oEvent.needPostBack = false;}
For deleting the from the button outside:
How will you identify that which row you want to delete ?
var row = // row you want to delete based on your condition and requirement
row.deleteRow();
thanks for the info.. I will try it out..
I am really annoyed at this new grid, the ultrawebgrid was so much better.
having to rebind the dataset every time to the grid just plain sucks.
I misunderstood the grid and I gave you the code for ultrawebgrid.
yup, didn't work...
Can't use ultragrid anymore... they locked it out of net 4.0
Do you have some sample code for the webdatagrid?
No, I didn't have sample code for webdatagrid.