|
Rank: Member Groups: Member
Joined: 7/10/2009 Posts: 10
|
Hi, my code is as shown below.
Dim item As EO.Web.GridItem Dim strVisibility As String For Each item In GridTemplateObject.CheckedItems 'item.Deleted = True Dim item1 As String = CStr(item.Cells(2).Value) Dim Visibility As String = CStr(item.Cells(5).Value) strVisibility = "1" ds = prp.GetManageTemplateFillTables(item1, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID")) Dim strType As String Dim strUpdatable As String If Not ds Is Nothing Then strUpdatable = 1 If ds.Tables(0).Rows.Count > 0 Then If (ds.Tables(0).Rows(0)("VISIBILITY")) <> 1 Then 'updating visibility 'msgcode = prp.UpdateTemplateVisibility(item1, strVisibility, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID")) 'If msgcode <> "0" Then ' showsystemmsg(Page, msgcode) 'Else ' showsystemmsg(Page, "Record Successfully Saved")
'End If
End If
End If Else msgcode = prp.AddTemplateTable(item1, "", strType, strVisibility, "", strUpdatable, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID"))
End If
Next item GridTemplateObject.CheckedItems
i want to retrieve the selected checked items in the grid view.for the logic i am using is GridTemplateObject.CheckedItems it is retrieving rows but only bringing the rows that are already available rows from the db.it is not giving me the check box selected items if i am selecting some of the check boxws in the Grid.
Waiting for reply Thanks Uday
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
CheckedItems is the correct property, but it is only based on the first CheckBoxColumn. In any case you can always walk through all rows and check the specific cell value to see if it is checked.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 7/10/2009 Posts: 10
|
Hi,
As answer to the below post you have given:
In any case you can always walk through all rows and check the specific cell value to see if it is checked.
Could you please provide an example to walk through all the rows and check for specific checked values.
Thanks Uday
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, It will be something like this:
Code: Visual Basic.NET
For Each item As EO.Web.GridItem In Grid1.Items
'Check whether the first cell is checked. Obviously if
'your CheckBoxColumn is not the first column, you will
'need to change the column index. For example, if it is the
'second column, you will need to change it to item.Cells(1)
If item.Cells(0).Value = True Then
'The cell is checked, now do whatever you need to do
.....
End If
Next
If the column data type is not boolean (bit in your db), your cell value may not be "True" (for example, may be "Yes"). In that case put a break point in debugger and check the value of the Cell. It will tell you what value means it is checked and what value means it is not checked. Thanks! Thanks
|
|
Rank: Member Groups: Member
Joined: 7/10/2009 Posts: 10
|
Hi,
Below code works fine for the check box values retrieving from the data base. If i have selected some additional check items in to the grid. Those items are not avilable
when i am looping thru it. For Each item As EO.Web.GridItem In Grid1.Items //retrives values only from data base and not from the grid when user is chebox is checked.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Can you explain what exactly do you mean "those items are not available"? We asked you to check the cell value, so please also explain what that has to do with retreiving the cell value too. If necessary, please describe it in a step by step manner. For example, step 1: The Grid is populated with 3 items; step 2: I checked the first cell on the second row; etc. We have to understand your question clearly in order to help you.
Thanks
|
|
Rank: Member Groups: Member
Joined: 7/10/2009 Posts: 10
|
Hi, I have one eo grid,server side button on the form.
1)I have populated the values in to eo:Grid from the data base.(has 6 columns and the 5th column is visibility and this is a check box.
my intetion is 2)when user selects check box item and clicks on a button (update functionality Has to happen).
Problem: in the buton code i am checking for the selected item(visibility) on the screen which user checks the check boxes(my 5th column) if item selected //some functionality has to happen i am using the code provided in this site. For Each item In GridTemplateObject.CheckedItems If item.Cells(5).Value = True Then
//here it is loops all the items which are checked true and updated in the data base.(means it loops only if it comes from data base) //suppose user selects some item from the grid that item is not looped. here i am also using button trigger event. Code in eo grid as well as button control is shown below. in eo grid ascx file code. <eo:CallbackPanel runat="server" id="CallbackPanelTemplateObj" AutoDisableContents="True" BorderWidth=0 width="100%" LoadingHTML="<%$ Resources:Callback,LoadingHTMLTextOnly %>" GroupName="MultipleLo" Triggers="{ControlID:Button1;Parameter:}"> <div style="width:100%"> <eo:Grid runat="server" id="GridTemplateObject" BorderColor="#828790" BorderWidth="0px" GridLines=Both FixedColumnCount="0" ColumnHeaderDescImage="00050205" GridLineColor="240, 240, 240" ColumnHeaderAscImage="00050204" ColumnHeaderHeight="20" Font-Size="10pt" Font-Names="Tahoma" EnableTheming="true" EnableKeyboardNavigation="True" height="300" ScrollBars="both" FullRowMode="True" AllowColumnReorder="False" ItemHeight=22 IsCallbackByMe="False" ClientSideOnContextMenu="ShowContextMenuTemplateObj" ColumnHeaderDividerImage="00050103" RunningMode=client > <ItemStyles > <eo:GridItemStyleSet > <ItemHoverStyle CssText="background-color:ThreeDLighShadow"></ItemHoverStyle> <SelectedStyle CssText="background-color: lightblue;"></SelectedStyle> <CellStyle CssText="padding-left:2px;padding-top:2px;"></CellStyle> <ItemStyle CssText="background-color: white;"></ItemStyle> </eo:GridItemStyleSet> </ItemStyles> <ContentPaneStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;"></ContentPaneStyle> <ColumnHeaderStyle CssText="background-color:#FFF0BA"></ColumnHeaderStyle> <ColumnTemplates> </ColumnTemplates> <Columns> <eo:RowNumberColumn AllowResize="False" AllowSort="True" HeaderText="" Width="80" DataField=""></eo:RowNumberColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="Id" Width="0" DataField="ID"></eo:StaticColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="DB Name" Width="200" DataField="ACTUAL_NAME"></eo:StaticColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="Screen Name" Width="200" DataField="SCREEN_NAME"></eo:StaticColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="Type of Object" Width="200" DataField="OBJECT_TYPE"></eo:StaticColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="Visibility" Width="0" DataField="VISIBILITY"></eo:StaticColumn> <eo:CheckBoxColumn AllowSort="True" DataField="VISIBILITY" HeaderText="Visibility" Name="chkVisibility" > <CheckBoxStyle CssText="text-align: left" /> <CellStyle CssText="text-align: left" /> </eo:CheckBoxColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="Search Condition" Width="200" DataField="SEARCH_CONDITION"></eo:StaticColumn> <eo:StaticColumn AllowResize="True" AllowSort="True" HeaderText="" Width="0" DataField="UPDATABLE"></eo:StaticColumn> </Columns> </eo:Grid> <p> <div id="divInfo" visible="true"></div> </P> </div> <asp:label runat="server" ID="Label52" Width=0></asp:label> <asp:Button id="Button1" runat="server" Text="Bulk Visibility"></asp:Button> </eo:CallbackPanel>
//code to retrieve the selected items from check box.(this is written in button control). Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Dim item As EO.Web.GridItem Dim strVisibility As String 'Dim cell As EO.Web.GridCell Dim text As String 'For Each item In GridTemplateObject.CheckedItems For Each item As EO.Web.GridItem In GridTemplateObject.Items
If (IsDBNull(item.Cells(5).Value)) Then Continue For End If
If item.Cells(5).Value = True Then 'item.Deleted = True Dim item1 As String = CStr(item.Cells(2).Value) Dim Visibility As String = CStr(item.Cells(5).Value) strVisibility = "1" ds = prp.GetManageTemplateFillTables(item1, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID")) Dim strType As String Dim strUpdatable As String If Not ds Is Nothing Then strUpdatable = 1 If ds.Tables(0).Rows.Count > 0 Then If (ds.Tables(0).Rows(0)("VISIBILITY")) <> 1 Then 'updating visibility 'msgcode = prp.UpdateTemplateVisibility(item1, strVisibility, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID")) 'If msgcode <> "0" Then ' showsystemmsg(Page, msgcode) 'Else ' showsystemmsg(Page, "Record Successfully Saved")
'End If
End If
End If Else msgcode = prp.AddTemplateTable(item1, "", strType, strVisibility, "", strUpdatable, HttpContext.Current.Session("USERID"), HttpContext.Current.Session("USERPWD"), HttpContext.Current.Session("Session_UserID"))
End If End If
Next item
'Dim refreshopener As String 'refreshopener = "<script>window.opener.PopUpTemplateObjectCallBack();</script>" ''refreshopener = refreshopener + "<script>window.close()</script>" 'Page.RegisterClientScriptBlock("PostBackParent", refreshopener) End Sub
Thanks Uday
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks fine to us. However we do not review any code related to your own business logic/database. So you will want to isolate the problem first.
Let's say you have the Grid populated with 4 rows. Then user checked the checkbox on the 2nd row (on the 5th column) and then click Button1 to submit the change. Now you are back on the server side inside your Button1_Click event, and the questions are:
1. What is the value of Grid1.Items(1).Cells(4)? (This cell is checked) 2. What is the value of Grid1.Items(0).Cells(4)? (Assume this cell was not initially checked and user did not check it) 3. Are these two value the same?
If the answer for the last question is No, then the Grid is working correctly. If it is Yes, then please create a test page to demonstrate the problem. In either case it should have nothing to do with your database. So make sure your test page contains nothing related to your database. If you need the Grid to be populated from a data source, create a DataTable/DataSet object with code to demonstrate the problem.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 7/10/2009 Posts: 10
|
Hi, 1). What is the value of Grid1.Items(1).Cells(4)? (This cell is checked) Ans if the cell is checked the value shown is System.DBNull(which is wrong and need to show 1)
Note:for this reason i have written If (IsDBNull(item.Cells(5).Value)) Then Continue For End If //so that it will continue looping else it is terminating abruptly.
2). What is the value of Grid1.Items(0).Cells(4)? (Assume this cell was not initially checked and user did not check it) Ans)Here the value is 1.
Thanks Uday
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You said its the 5th column. So it should be item.Cells(4).Value, not item.Cells(5).Value. I am not sure if that is the problem or a typo. If it was a typo, then the values doesn't make sense. Please provide a test page and we will be happy to take a look. See here for the requirments for test page: http://www.essentialobjects.com/forum/postst3013_I-run-into-a-problem-can-I-send-over-my-code-so-that-you-can-take-a-look.aspxThanks
|
|