Hii;
I want to update record in my webdatagrid using webdialogwindow with textboxes in it can you please suggest me how can i do it. Post that you have posted earlier is good but can you please suggest me some other way i can do it .I am attaching my code please help me
<script type="text/javascript">
function PromptEdit(sControlID){
oWebDialogWindow1 = $find(sControlID); oWebDialogWindow1.set_windowState($IG.DialogWindowState.Normal);
}
function Confirm() { oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
} function Cancel() { oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden); }
function DeleteRow() {
var grid = $find('<%= WebDataGrid1.ClientID %>'); var gridRows = grid.get_rows()
var selectedRows = grid.get_behaviors().get_selection().get_selectedRows();
var rows = new Array(); var i1 = 0;
for (var i = selectedRows.get_length() - 1; i >= 0; i--) {
rows[i1] = selectedRows.getItem(i); i1++; }
grid.get_behaviors().get_editingCore().get_behaviors().get_rowDeleting().deleteRows(rows);
</script> <style type="text/css"> .igg_ActiveCell { color: white; background-image: url("ig_res/Default/images/Activebg.gif"); } </style></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:HiddenField ID="hdnID" runat="server" /> <div id="wrapper" class="wgDataBind"> <asp:ScriptManager ID="scriptManager1" runat="server"> </asp:ScriptManager> <div id="container"> <%-- <div id="headerContainer" class="ControlPanelHeader"> <img alt="Configuration" src="ig_res/Default/images/config.png" /> Control Panel </div>--%> <%-- <div id="countContainer" class="controlPanel"> <div id="eventList" class="controlPanelEvent"> <asp:CheckBox ID="ActivationOn" Text="ActivationOn:" AutoPostBack="true" Checked="true" runat="server" TextAlign="Left" OnCheckedChanged="ActivationOn_CheckedChanged" /> </div>--%> <div id="DataGridWrapper"> <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="false" AutoCRUD="True" DefaultColumnWidth="100px" DataKeyFields="ID" OnRowAdded="WebDataGrid1_RowAdded"> <AjaxIndicator Enabled="False" /> <Columns> <ig:TemplateDataField Key="DeleteItem" Width="60px"> <ItemTemplate> <asp:ImageButton runat="server" ID="DeleteItem" AlternateText="DeleteButton" ImageUrl="~/ig_res/Default/images/DeleteIcon_en.PNG" OnClientClick="DeleteRow(); return false;" /> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="EditItem" Width="60px"> <ItemTemplate> <img onclick="PromptEdit('<%= WebDialogWindow1.ClientID %>')" src="ig_res/Default/images/button_edit.png" alt="edit" width="70" height="23" /> </ItemTemplate> </ig:TemplateDataField> <ig:BoundDataField Header-Text="ID" DataFieldName="ID" Key="ID"> </ig:BoundDataField> <ig:BoundDataField Header-Text="FirstName" DataFieldName="FirstName" Key="FirstName"> </ig:BoundDataField> <ig:BoundDataField Header-Text="LastName" DataFieldName="LastName" Key="LastName"> </ig:BoundDataField> <ig:BoundDataField Header-Text="City" DataFieldName="City" Key="City"> </ig:BoundDataField> <ig:BoundDataField Header-Text="Country" DataFieldName="Country" Key="Country"> </ig:BoundDataField> </Columns> <%-- <Behaviors> <ig:Filtering Alignment="Top" Visibility="Visible" Enabled="True" FilterType="ExcelStyleFilter" > <ColumnSettings> <ig:ColumnFilteringSetting ColumnKey="City" Enabled="False" /> </ColumnSettings> </ig:Filtering> <ig:Paging PagerAppearance="Bottom" PageSize="10" Enabled="true" /> <ig:Activation ActiveCellCssClass="igg_ActiveCell" Enabled="true" /> </Behaviors>--%> <Behaviors> <ig:Activation ActiveCellCssClass="igg_ActiveCell" Enabled="true" /> <ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Row" /> <ig:Paging PagerAppearance="Bottom" PageSize="6" Enabled="true" /> <ig:RowSelectors Enabled="true" RowNumbering="true" /> <ig:Sorting SortingMode="Single" Enabled="true" /> <ig:ColumnMoving Enabled="true" /> <ig:ColumnResizing Enabled="true" /> <ig:EditingCore> <Behaviors> <%-- <ig:RowEditing EditModeActions-EnableF2="true" EditModeActions-MouseClick="Single" Enabled="true"> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="ID" ReadOnly="true" /> </ColumnSettings> </ig:RowEditing>--%> <ig:RowAdding Alignment="Top" EditModeActions-EnableF2="true" EditModeActions-EnableOnActive="true" EditModeActions-MouseClick="Single" Enabled="true" /> <ig:RowDeleting Enabled="true"> </ig:RowDeleting> </Behaviors> </ig:EditingCore> <ig:ColumnFixing ShowLeftSeparator="true" ShowRightSeparator="true" AutoAdjustCells="true"> <ColumnSettings> <ig:ColumnFixingSetting FixButtonAlignment="Left" ColumnKey="FirstName" EnableFixing="True" FixLocation="Left" /> </ColumnSettings> </ig:ColumnFixing> <ig:Filtering Alignment="Top" Visibility="Visible" Enabled="true" AnimationEnabled="True" /> <ig:SummaryRow Enabled="true" /> </Behaviors> <EditorProviders> <ig:TextEditorProvider ID="WebTextEditProvider1" /> </EditorProviders> </ig:WebDataGrid> <div id="Div1" class="dwConfirmationDialog"> <%-- <div id="ResetButton"> <img onclick="PromptEdit('<%= WebDialogWindow1.ClientID %>')" src="ig_res/Default/images/button_edit.png" alt="edit" width="87" height="23" /></div>--%> <ig:WebDialogWindow runat="server" ID="WebDialogWindow1" InitialLocation="Centered" DataKeyField="ID" Height="150px" Width="286px" Modal="true" WindowState="Hidden" Style="line-height: normal" > <Header CaptionAlignment="Left" CaptionText="Update Data Here"> <CloseBox Visible="False" /> </Header> <ContentPane BackColor="White"> <Template> <asp:Label ID="lblFirstName" runat="server" Text='FirstName:'></asp:Label> <asp:TextBox ID="txtFirstName" runat="server" Style="margin-left: 1px" Text='<%#Eval("FirstName") %>'></asp:TextBox><br /> <asp:Label ID="lblLastName" runat="server" Text='LastName:'></asp:Label> <asp:TextBox ID="txtLastName" runat="server" Style="margin-left: 1px" Text='<%#Eval("LastName") %>'></asp:TextBox> <br /> <asp:Label ID="lblCity" runat="server" Text='City:'></asp:Label> <asp:TextBox ID="txtCity" runat="server" Style="margin-left: 31px" Text='<%#Eval("city") %>'></asp:TextBox> <br /> <asp:Label ID="lblCountry" runat="server" Text='Country:'></asp:Label> <asp:TextBox ID="txtCountry" runat="server" Style="margin-left: 12px" Text='<%#Eval("Country") %>'></asp:TextBox> <br /> <div style="position: absolute; right: 5px; top: 120px; height: 23px"> <img onclick="Confirm()" style="cursor: hand;" src="ig_res/Default/images/button_save.png" alt="Update" width="43" height="23" /> <img onclick="Cancel()" style="cursor: hand;" src="ig_res/Default/images/button_cancel.png" alt="Cancel" width="43" height="23" /> </div> </div> </Template> </ContentPane> </ig:WebDialogWindow> </div> </div> </div> </div> <asp:SqlDataSource ID="srcEmployees" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|MyData.mdf;Integrated Security=True;User Instance=True" SelectCommand="SELECT ID,FirstName,LastName,City,Country FROM EmployeeDetails" InsertCommand="Insert into EmployeeDetails(FirstName,LastName,city,country) values (@FirstName,@LastName,@city,@country)" DeleteCommand="Delete From EmployeeDetails where ID=@ID" UpdateCommand="Update EmployeeDetails set FirstName=@FirstName,LastName=@LastName,city=@city,country=@country where ID=@ID" runat="server"></asp:SqlDataSource></asp:Content>
Hello Surbhi Bhatnagar,
Thank you for posting in our forums!
Is there any specific reason you need to do this in a WebDialogWindow? The grid has a built in feature called the RowEditTemplate that performs the same functions as the situation you are describing.
I would recommend looking into using the RowEditTemplate behavior and going over the following sample and documentation for more information on using the RowEditTemplate.
http://www.infragistics.com/products/aspnet/sample/data-grid/custom-edit-row-template
http://help.infragistics.com/doc/ASPNET/2014.1/CLR4.0/?page=WebDataGrid_Enabling_Row_Editing_Template.html
If you require any further assistance with this, please let me know and I will be glad to help.
if i specifically want to update or add data using WebDialogWindow how can i do it.
Hi Surbhi Bhatnagar,
In order to update the WebDataGrid from a WebDialogWindow, you will need to update the grid through javascript.
You will need to know which GridRow is being edited, you can then get the GridCell and call the set_value() method on the cell. To add a row, you can call grid.get_rows().add() and pass in the values for the new row.
You can find more information on our grid's client-side object model in our documentation here:
http://help.infragistics.com/doc/ASPNET/2014.1/CLR4.0/?page=WebDataGrid~Infragistics.Web.UI_namespace.html
If you have any further questions or concerns with this, please let me know.
Please let me know if you need further assistance with this issue.