I am trying to enable 2 Way DataBinding and CRUD operations. So far I only have the "Update" working, the "Add" failes to save (I haven't tested delete). The culprit seems to be the fact that I am unable to get the BaseTableName to "stick" in the Designer for the Band Properties. As soon as I Save it and then go back in, it is gone. I am under the "Edit Data Structure" -> "Bands and Columns" and I have the (only) Band selected. I have also tried prefixing the table name with "dbo." it still won't take it. As soon as I click the "Save" button (which is just a "submit" button, right?) the new row goes away. (Any row/field changes work great..)
I have also tried adding the "BaseTableName" to the asp code and still the Add doesn't work.
Any ideas?
Update...
I did test "Delete" and it works. I just cant get the Add working, I even created a handler for "Updated" and the even isn't being fired by the "WebGrid".
This weekend I treid the online tutorial and the even bought the online class. I am still unable to implement a "basic" 2 way databind "add' feature. The Update and the delete works fine on all my tests. Could it be something with SQL? I have full control on the dbs I have created for test. I have tried Primary Keys with "Auto Generate" (Identity) and without Identity. I just dont get it. As soon as my postback fires the added row disappears from the grid. It really baffles me because the change and the deletse work great.
Without looking at your code and your markup, I don't think anyone is going to be able to guess what's causing your problem.
If you post your code and markup, I'll look at it. (Somebody who knows more than I do may also look at it. ;-)
Here is my code.
I have tired SQL datasources and Access Datasources. No matter what I do the "BaseTableName" doesn't save. I can put it in the markup, but it still wont add records. (It will save and delete records from the grid, with or without the "BaseTableName" in the markup!)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ShayneInfragisticsTestConnectionString %>"
DeleteCommand="DELETE FROM [Orders] WHERE [ID] = @original_ID AND [OrderNum] = @original_OrderNum AND [OrderDescription] = @original_OrderDescription AND [Total] = @original_Total"
InsertCommand="INSERT INTO [Orders] ([OrderNum], [OrderDescription], [Total]) VALUES (@OrderNum, @OrderDescription, @Total)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Orders]"
UpdateCommand="UPDATE [Orders] SET [OrderNum] = @OrderNum, [OrderDescription] = @OrderDescription, [Total] = @Total WHERE [ID] = @original_ID AND [OrderNum] = @original_OrderNum AND [OrderDescription] = @original_OrderDescription AND [Total] = @original_Total">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_OrderNum" Type="String" />
<asp:Parameter Name="original_OrderDescription" Type="String" />
<asp:Parameter Name="original_Total" Type="Decimal" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="OrderNum" Type="String" />
<asp:Parameter Name="OrderDescription" Type="String" />
<asp:Parameter Name="Total" Type="Decimal" />
</UpdateParameters>
<InsertParameters>
</InsertParameters>
</asp:SqlDataSource>
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Browser="Xml"
DataKeyField="ID" DataSourceID="SqlDataSource1" Height="211px" Width="497px">
<bands>
<igtbl:UltraGridBand AllowAdd="Yes" AllowDelete="Yes" AllowUpdate="Yes"
DataKeyField="ID" BaseTableName="Orders">
<Columns>
<igtbl:UltraGridColumn BaseColumnName="ID" DataType="System.Int32"
IsBound="True" Key="ID">
<Header Caption="ID">
</Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn BaseColumnName="OrderNum" IsBound="True" Key="OrderNum">
<Header Caption="OrderNum">
<RowLayoutColumnInfo OriginX="1" />
<Footer>
</Footer>
<igtbl:UltraGridColumn BaseColumnName="OrderDescription" IsBound="True"
Key="OrderDescription">
<Header Caption="OrderDescription">
<RowLayoutColumnInfo OriginX="2" />
<igtbl:UltraGridColumn BaseColumnName="Total" DataType="System.Decimal"
IsBound="True" Key="Total">
<Header Caption="Total">
<RowLayoutColumnInfo OriginX="3" />
</Columns>
<addnewrow view="NotSet" visible="NotSet">
</addnewrow>
</igtbl:UltraGridBand>
</bands>
<displaylayout allowaddnewdefault="Yes" allowcolsizingdefault="Free"
allowcolumnmovingdefault="OnServer" allowdeletedefault="Yes"
allowsortingdefault="OnClient" allowupdatedefault="Yes"
bordercollapsedefault="Separate" headerclickactiondefault="SortMulti"
loadondemand="Xml" name="UltraWebGrid1" rowheightdefault="20px"
rowselectorsdefault="No" selecttyperowdefault="Extended"
stationarymargins="Header" stationarymarginsoutlookgroupby="True"
tablelayout="Fixed" version="4.00" viewtype="OutlookGroupBy">
<framestyle backcolor="Window" bordercolor="InactiveCaption"
borderstyle="Solid" borderwidth="1px" font-names="Microsoft Sans Serif"
font-size="8.25pt" height="211px" width="497px">
</framestyle>
<pager minimumpagesfordisplay="2">
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
<borderdetails colorleft="White" colortop="White" widthleft="1px"
widthtop="1px" />
</PagerStyle>
</pager>
<editcellstyledefault borderstyle="None" borderwidth="0px">
</editcellstyledefault>
<footerstyledefault backcolor="LightGray" borderstyle="Solid" borderwidth="1px">
</footerstyledefault>
<headerstyledefault backcolor="LightGray" borderstyle="Solid"
horizontalalign="Left">
</headerstyledefault>
<rowstyledefault backcolor="Window" bordercolor="Silver" borderstyle="Solid"
borderwidth="1px" font-names="Microsoft Sans Serif" font-size="8.25pt">
<padding left="3px" />
<borderdetails colorleft="Window" colortop="Window" />
</rowstyledefault>
<groupbyrowstyledefault backcolor="Control" bordercolor="Window">
</groupbyrowstyledefault>
<groupbybox>
<boxstyle backcolor="ActiveBorder" bordercolor="Window">
</boxstyle>
</groupbybox>
<addnewbox hidden="False">
<boxstyle backcolor="Window" bordercolor="InactiveCaption" borderstyle="Solid"
borderwidth="1px">
</addnewbox>
<activationobject bordercolor="" borderwidth="">
</activationobject>
<filteroptionsdefault>
<filterdropdownstyle backcolor="White" bordercolor="Silver" borderstyle="Solid"
borderwidth="1px" customrules="overflow:auto;"
font-names="Verdana,Arial,Helvetica,sans-serif" font-size="11px" height="300px"
width="200px">
<padding left="2px" />
</filterdropdownstyle>
<filterhighlightrowstyle backcolor="#151C55" forecolor="White">
</filterhighlightrowstyle>
<filteroperanddropdownstyle backcolor="White" bordercolor="Silver"
borderstyle="Solid" borderwidth="1px" customrules="overflow:auto;"
font-names="Verdana,Arial,Helvetica,sans-serif" font-size="11px">
</filteroperanddropdownstyle>
</filteroptionsdefault>
</displaylayout>
</igtbl:UltraWebGrid>
<asp:Button ID="Button1" runat="server" Text="Save" />
</form>
shaynejud said:No matter what I do the "BaseTableName" doesn't save.
I don't see any code that would add new records to the underlying database. You might find this Knowledge Base article helpful:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9966
The two way autobind is actually "codeless" (you are probably thinking of older versions of WebGrid).
(Rumen, the Infragistics Employee that posted in my "other" thread" summed it up well:
Hello,
In two-way databinding (automaticallly updating the database), you will typically also need to have BaseTableName defined as well. For example:
<igtbl:UltraGridBand DataKeyField="CustomerID" BaseTableName="Customers">
Also, if you are using AccessDataSource, SqlDataSuorce, etc, make sure you generate the CRUD commands in design time by clicking the Advanced button and the selecting "Generate CRUD..." )
This is exaclty what I was testing. (I have a new programmer fresh from college and I am basically trying to give him some assignments and I am looking for some RAD tools so we can get some prototypes up asap. (Just to give you some background.)
I didn't put any "code" in for the delete or the change and they work. :)