iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Currently the user has to click on the WebGrid Column and either Double-Click or start typing to get the DropDownList to appear.
How do I initailly set the WebGrid in Edit Mode on either the Current Row and/or All Rows?
<%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Data" %> <%@ Register assembly="ISNet.WebUI.WebGrid" namespace="ISNet.WebUI.WebGrid" tagprefix="ISWebGrid" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script runat="server"> protected void _WebGrid_InitializeLayout(object sender, LayoutEventArgs e) { ISNet.WebUI.WebGrid.WebValueList Priority_WebValueList = _WebGrid.GetTableByName("").Columns.GetNamedItem("Priority_WebGridColumn").ValueList; SortedList Priority_SortedList = new SortedList(); Priority_SortedList.Add("ASSESS - 1", "1"); Priority_SortedList.Add("ASSESS - 2", "2"); Priority_SortedList.Add("ASSESS - 3", "3"); Priority_SortedList.Add("DISPOSE", "D"); Priority_SortedList.Add("UNDECIDED", ""); Priority_WebValueList.DataSource = Priority_SortedList; Priority_WebValueList.DataTextField = "Key"; Priority_WebValueList.DataValueField = "Value"; RefurbPriority_DropDownList.DataSource = Priority_SortedList; RefurbPriority_DropDownList.DataTextField = "Key"; RefurbPriority_DropDownList.DataValueField = "Value"; RefurbPriority_DropDownList.SelectedValue = ""; RefurbPriority_DropDownList.DataBind(); } protected void Company_DropDownList_PreRender(object sender, EventArgs e) { DropDownList _DropDownList = (DropDownList) sender; _DropDownList.Items.Insert(0, "--- PLEASE SELECT ---"); } </script> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td>PRIORITY</td> <td>COMPANY</td> </tr> <tr> <td> <ASP:DROPDOWNLIST ID="RefurbPriority_DropDownList" runat="server" > </ASP:DROPDOWNLIST> </td> <td> <ASP:DROPDOWNLIST ID="Company_DropDownList" runat="server" DataValueField="CustomerID" DataTextField="CompanyName" DataSourceID="Company_SqlDataSource" onPreRender="Company_DropDownList_PreRender" > </ASP:DROPDOWNLIST> </td> </tr> <tr> <td colspan="2"> <ISWebGrid:WebGrid ID="_WebGrid" runat="server" DataSourceID="Orders_SqlDataSource" Height="250px" UseDefaultStyle="True" DefaultStyleMode="Win7" OnInitializeLayout="_WebGrid_InitializeLayout" > <LayoutSettings AllowEdit="Yes" AllowSorting="Yes" AllowBatchUpdate="true" > <BatchUpdateSettings AllowReviewChanges="true" AutomaticObjectUpdate="false" /> </LayoutSettings> <RootTable DataKeyField="OrderID" > <Columns> <ISWebGrid:WebGridColumn Name="Priority_WebGridColumn" Bound="True" DataMember="REFURB_PRIORITY" EditType="DropdownList" Caption="PRIORITY" Width="100px" NullText="" DefaultValue="" InputRequired="true" InputRequiredErrorText="Priority Needed" > </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Name="Company_WebGridColumn" Bound="True" EditType="DropdownList" Caption="Company" Width="100px" InputRequired="false" > <ValueList DataSourceID="Company_SqlDataSource" DataTextField="CompanyName" DataValueField="CustomerID" > </ValueList> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Order ID" EditType="NoEdit" DataMember="OrderID" Name="OrderID_WebGridColumn" Width="100px" > <CellStyle ForeColor="Black"/> </ISWebGrid:WebGridColumn> </Columns> </RootTable> </ISWebGrid:WebGrid> </td> </tr> </table> <asp:SqlDataSource ID="Company_SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2005 %>" SelectCommand="SELECT [CustomerID], [CompanyName] FROM [Customers] ORDER BY [CustomerID]" ></asp:SqlDataSource> <asp:SqlDataSource ID="Orders_SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2005 %>" SelectCommand="SELECT TOP 5 [OrderID], [CustomerID], '' AS REFURB_PRIORITY, '' AS GRAPHICS_NEW FROM [Orders] ORDER BY [OrderID]" ></asp:SqlDataSource> </div> </form> </body> </html>
The following setting helps a lot.
WebGrid - LayoutSettings - EditOnClick
Doug
Hi Douglas,
Thank you for detail information. However, it will be great if in some other time, you can kindly send the code as an attachment file. I will really appreciate that.
If we integrate the DropDownList to WebGrid, we do not have that kind of behavior that showing dropdown list on initialize, however, we do have a workaround on this scenario. In order to do so, we will need to use CellTemplate and integrate it to our WebGrid. Attached is a sample of cellTemplate using dropdownlist. One thing to remember is, you will need to put the "cellTemplate_dp.cs" on your App_Code folder. On "cellTemplate_dp.cs", we will create a dropdownlist template and call these on our back end.
I hope it helps and please, do not hesitate to ask if you have any other questions. Thank you.
Best Regards,
Andi Santoso
Hi,Does this effectively do the same thing?
<ISWebGrid:WebGridColumn Name="PriorityCellTemplate_WebGridColumn" Bound="False" Caption="PRIORITY" ColumnType="Template" Width="100px" > <CellTemplate> <asp:DropDownList ID="RefurbPriority_DropDownList" runat="server" SelectedValue='<%# Bind("REFURB_PRIORITY") %>' > <asp:ListItem Text="ASSESS - 1" Value="1" /> <asp:ListItem Text="ASSESS - 2" Value="2" /> <asp:ListItem Text="ASSESS - 3" Value="3" /> <asp:ListItem Text="DISPOSE" Value="D" /> <asp:ListItem Text="UNDECIDED" Value="" Selected="True" /> </ASP:DropDownList> </CellTemplate> </ISWebGrid:WebGridColumn>
If so, and as with your example when the following is added, LayoutSettings.AllowBatchUpdate and BatchUpdateSettings.AllowReviewChanges does not recognize changes to the Controls in the Template.
What needs to be added?
Thanks,
Yes, it would be the same. The different is, mine is created at behind code and yours is not. Attached is a sample on how to let the WebGrid recognize the changes on TemplateCell and on how to access the child control in server side. To access the child control, on WebGrid_OnInitializeRow server side, you will need to get the specific cell and assign as a template object. Before that, on you cs file, you will need to define what are the attribute for the Template cell its self.
Hi,
It is still not working completely.
As for the pending changes issue, when using the "Reviewing Pending Changes" Feature, all that is displayed in the Changes Column is "}". As a result, the changes can not be undone.
As in my example, when the ColumnType is not a Template and the EditType is DropdownList, the Changes Column displays something like "{Priority_WebGridColumn=ASSESS -3}". Plus, the changes can be undone.
What is still missing?
Is there a better way to do all this?
- Register the Control with the BatchUpdate, AllowReviewChanges Features so we don't have to try to emulate it.
- Another approach to setting the Row into Edit Mode
Unfortunately, there are no better way in doing this scenario. It is only a workaround and it is kind of hard if we want to threat this cell as a regular cell since it is only a template. Because cell template is only attached on the WebGrid and not attached to a physical database. For instance, we have a database with 4 attributes on it, then we create another 5th column of cell template and I do not think that we can include the data to restore into our database which only has 4 attributes on it.
So, I hope it helps and please, do not hesitate to ask if you have any other questions. Thank you.
Apparently, you have sent me down a dead end from the beginning.
You said to use a Template.
My code example in my intial posting 3 days ago had the following properties:
- LayoutSettings.AllowBatchUpdate="true"
- LayoutSettings.BatchUpdateSettings.AllowReviewChanges="true"
Now I understand you don't know how to make LayoutSettings.BatchUpdateSettings.AllowReviewChanges="true" work with Templates because it is kind of hard.
What do the developers say?
So, I try to forge ahead without the AllowReviewChanges and now AllowBatchUpdate is not working.
In the Server Side BatchUpdate Event
- there are e.PendingChanges
- WebRowChanges.RowState is Modified
But
- WebRowChanges.Data is null
What am I to do?
On top of that, the WebGrid Styles do not cascade to the DropDownList, even in your examples. I have not figured out what the WebGrid Styles are so I can apply them to the DropDownList.
You said "Because cell template is only attached on the WebGrid and not attached to a physical database.".
So, how do we attach the template to the physical database?
I am so sorry for the mistaken. I have forwarded this issue to our developer. This scenario, actually. is not being prepared and, by using template cell in batch update is not supported yet. I have already submitted this as a feature request to our developer team. At this moment, the best workaround is, by using a dropdown list as an edit type. Sorry for the inconvenience.
I hope it helps. Thank you.
What is the status of the feature request to the developer team to support batch update in a template cell?
Dear Douglas,
First of all, deeply apologize. It seems that the issue is still under investigation on our Developer Team Department.
I have followed them up with a high priority, I will surely let you know as soon as possible when they've come with updates.
Thank you and have a nice day.
A nightly build hotfix for WebGrid has been build and it has fixed your issue. I have tried them and it works nicely at my end.
Please find the attachment and do not hesitate to let me know if you have any further questions. Thank you and have a nice day.
Noted that this is a nightly build, any feedback regarding this build is really appreciated.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname