I have an UltraWebGrid bound to a Data Source...
At this point, the entire Grid I created is controlled through choices I have made in the Designer. (Of course, I can do some coding if necessary).
I would like to assign a "DefaultValue" for a particular column so that when a new row is added that column takes on the current DateTime (the column is "DateAdded"...duh...). Inside the Designer the "DefaultValue" is greyed out and i am unable to type anything there. Can someone tell me how to accomplish what I am trying to do? (If I can do it in the designer, that would be nice, if not I can do "code behind". I will be using C#.)
And while I am asking, is there an easy way to enable "CRUD" (Change, Upade, Detele) in the UltraWeb Grid or do I need to add a button for saving? I found the "add" button to add new rows and enabled the grid to allow column cahnges, etc. I just cant get the data to actually save. :)
Thanks for any adivce!Shayne
I tried everything I could think of to get the designer to accept a DefaultValue, with no luck. (Hopefully, an Infragistics staff member will chime in the help on that.)
I did find an article in the Online Docs that shows how to set a DefaultValue in the the code-behind. I didn't try it. The online docs are at http://help.infragistics.com/NetAdvantage/NET/2008.2/CLR2.0/ but the navigation scheme there is klunky. The article in question is here: (click here)
in UltraWebGrid1_InitializeLayout event using
e.Layout.Bands(0).Columns.FromKey("JobID").DefaultValue =
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..."
Here is more info on 2-way databinding:
Did you know that the grid supports automatic data updating through the datasource control? The days of complicated event handlers dealing with DataSets accepting and rejecting changes are over!! Let's take a SqlDataSource for an example of how to use this feature.
When you create the datasource be sure to click on the "advanced" when building the select statement. You'll see a checkbox for "generate insert, update and delete". Checking that box will enable the datasource to perform all of the 'crud' operations on your table. The grid will automatically update the data, but first a 'postback' must occur. I put a postback in quotes because it can be the traditional full page, or it can be an asynchronous AJAX style postback. If you want the database to be updated with each row modification, you can add a server-side "RowUpdate" event handler. Enabling the AJAX functionality of the grid (click the "Enable AJAX" checkbox in the smart tag at design-time, or set grid.DisplayLayout.LoadOnDemand=Xml) will make the updaterow happen asynchronously, making the entire update process transparent to the end user. If you can't get updating working, check to be sure you set the grid's DataKeyField and BaseTableName properties (Yes, I'm speaking from experience).
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.
shaynejud said: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.
That shouldn't happen. You might want to post your markup here, and/or send a copy to Developer Support, at:
http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx
They usually reply within a week, alghough the reply is sometimes "We have determined that this is a bug and we have reported it to the development team." In which case, the next hotfix may or may not include a fix to your problem. Or they may simply tell you how to fix your problem.
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>
As Ed suggested, I also suggest that you submit a support request so that a Developer Support Engineer can investigate your issue in-depth.
Actaully, I did that first thing this morning, you guys are just usually quicker. :)