In the _RowSelectionChanged Event, e.CurrentSelectedRows.Count shows 1 but the e.CurrentSelectedRows[0] is null. Why would this happen. The View state for the grid is enabled and the dataviewstate is also enabled.
If any one has come across this please let me know.
Thanks,
Hemant
Hi Hermant,
What version and build number are you using?
regards,David Young
David,
I am using Version=9.2.20092.2183 with .Net 2.0
Did you ever figure this out? I'm experiencing the same problem in v14.2
below is the html, javascript and c# code related to it. In short, when the users selects the row in the grid, it fires async post back to the server and the async postback reply is traped in the javascript code to display the required value.
For some reason this work's sometime and fails most of the time. I feel the Grid is not able to maintain its state.
<asp:UpdatePanel id="GridUpdatePanel" runat="server" UpdateMode="Conditional"> <contenttemplate><asp:Label id="turnback" runat="server" Text="" cssclass="errorMessage" __designer:wfdid="w133"></asp:Label> <ig:WebHierarchicalDataGrid id="dgkpi" runat="server" Width="1040px" Height="500px" __designer:wfdid="w134" EnableTheming="True" EnableDataViewState="True" DataKeyFields="MODEL_TRADITIONAL,SO,REQUIRED_DATE,PONUM,POLINE" StyleSetName="Default" DataMember="ParentTable" AutoGenerateColumns="False" OnRowSelectionChanged="dgkpi_RowSelectionChanged" OnInitializeRow="dgkpi_InitializeRow"><Columns><ig:TemplateDataField Width="20px" Key="Dummy"><ItemTemplate> <asp:CheckBox ID="cbselect" runat="server" EnableViewState="true" /> </ItemTemplate></ig:TemplateDataField><ig:BoundDataField DataFieldName="MODEL_TRADITIONAL" DataType="System.String" Width="20px" Key="MODEL_TRADITIONAL"><Header Text="M/T"></Header></ig:BoundDataField><ig:BoundDataField DataFieldName="WEEKSLATE" DataType="System.String" Width="35px" Key="WEEKSLATE"><Header Text="Wks. Late"></Header></ig:BoundDataField></Columns>
<ClientEvents AJAXResponse="GridAjaxResponse"></ClientEvents><Bands><ig:Band Key="ChildSection" DataMember="ChildTable" AutoGenerateColumns="False"><Columns><ig:BoundDataField DataFieldName="MODEL_TRADITIONAL" DataType="System.String" Width="20px" Key="MODEL_TRADITIONAL"><Header Text="M/T"></Header></ig:BoundDataField></Columns></ig:Band></Bands><Behaviors><ig:Selection CellClickAction="Row" RowSelectType="Single"><SelectionClientEvents RowSelectionChanging="rowSelectionChanging"></SelectionClientEvents><AutoPostBackFlags RowSelectionChanged="True"></AutoPostBackFlags></ig:Selection></Behaviors></ig:WebHierarchicalDataGrid> <BR /><TABLE cellSpacing=2 cellPadding=0 border=0><TBODY><TR><TD class="label">PO#:</TD><TD class="TextBox"><asp:TextBox id="txt_poread" runat="server" Width="80px" CssClass="textboxReadOnly" __designer:wfdid="w135" ReadOnly="True" name="txt_poread"></asp:TextBox></TD><TD class="label">PO Line:</TD><TD class="TextBox"><asp:TextBox id="txt_polineread" runat="server" Width="50px" CssClass="textboxReadOnly" __designer:wfdid="w136" ReadOnly="True" name="txt_polineread"></asp:TextBox></TD><TD class="label">Contract#:</TD><TD class="TextBox"><asp:TextBox id="txt_contractread" runat="server" Width="100px" CssClass="textboxReadOnly" __designer:wfdid="w137" ReadOnly="True" name="txt_contractread"></asp:TextBox></TD><TD class="label">Req. Date:</TD><TD class="TextBox"><asp:TextBox id="txt_reqdtread" runat="server" Width="80px" CssClass="textboxReadOnly" __designer:wfdid="w138" ReadOnly="True" name="txt_reqdtread"></asp:TextBox></TD><TD class="label">Ace Turnback:</TD><TD><asp:DropDownList id="dd_turnback" runat="server" CssClass="DropDownList" __designer:wfdid="w139" name="dd_turnback"></asp:DropDownList> </TD></TR><TR><TD class="label">Rev. Sch. Ship Date:</TD><TD><asp:TextBox id="txt_revshipdate" runat="server" Width="80px" CssClass="textbox" __designer:wfdid="w140" name='txt_revshipdate"' MaxLength="10"></asp:TextBox></TD><TD class="label">Ship Mode:</TD><TD><asp:DropDownList id="dd_shipmode" runat="server" __designer:wfdid="w141" name="dd_shipmode"></asp:DropDownList> </TD><TD class="label">Comments:</TD><TD class="TextBox" colSpan=5><asp:TextBox id="txt_comments" runat="server" CssClass="textArea" __designer:wfdid="w142" name="txt_comments" MaxLength="1000" width="500px" TextMode="MultiLine"></asp:TextBox> </TD></TR><TR><TD class="label">Otis Approved:</TD><TD><asp:DropDownList id="dd_otisapproved" runat="server" CssClass="DropDownList" __designer:wfdid="w143" name="dd_otisapproved"><asp:ListItem></asp:ListItem><asp:ListItem>Yes</asp:ListItem><asp:ListItem>No</asp:ListItem></asp:DropDownList> </TD><TD align=right colSpan=8><asp:Button id="btn_update" onclick="btn_update_Click" runat="server" Width="80px" CssClass="formBtn" Text="Update" __designer:wfdid="w144"></asp:Button> </TD></TR></TBODY></TABLE><BR /></contenttemplate> <triggers><asp:AsyncPostBackTrigger ControlID="btn_show" EventName="Click"></asp:AsyncPostBackTrigger><asp:AsyncPostBackTrigger ControlID="btn_update" EventName="Click"></asp:AsyncPostBackTrigger></triggers></asp:UpdatePanel>
//// JAVA SCRIPT ////function GridAjaxResponse(sender, e) { document.getElementById("ctl00_CPHSCT_txt_poread").value = e.get_gridResponseObject().AdditionalProperties.po; document.getElementById("ctl00_CPHSCT_txt_polineread").value = e.get_gridResponseObject().AdditionalProperties.poline; document.getElementById("ctl00_CPHSCT_txt_contractread").value = e.get_gridResponseObject().AdditionalProperties.contract;}
///row selection event //////
protected void dgkpi_RowSelectionChanged(object sender, SelectedRowEventArgs e) {
string vPo = ""; string vPoLine = ""; string vReqDt = ""; string vContract = ""; string vTurnBack = ""; string vRevShipDt = ""; string vShipMode = ""; string vComments = ""; string vOtisApproved = "";
if (e.CurrentSelectedRows.Count > 0 && e.CurrentSelectedRows[0] != null) {
vPo = DataBinder.Eval(e.CurrentSelectedRows[0].DataItem, "PONUM").ToString().Trim(); vPoLine = DataBinder.Eval(e.CurrentSelectedRows[0].DataItem, "POLINE").ToString(); vContract = DataBinder.Eval(e.CurrentSelectedRows[0].DataItem, "SO").ToString().Trim();
dgkpi.GridView.GridResponse.AdditionalProperties.Add("po", vPo); dgkpi.GridView.GridResponse.AdditionalProperties.Add("poline", vPoLine); dgkpi.GridView.GridResponse.AdditionalProperties.Add("contract", vContract); dgkpi.GridView.GridResponse.AdditionalProperties.Add("reqdt", vReqDt); dgkpi.GridView.GridResponse.AdditionalProperties.Add("turnback", vTurnBack); dgkpi.GridView.GridResponse.AdditionalProperties.Add("revshipdt", vRevShipDt); dgkpi.GridView.GridResponse.AdditionalProperties.Add("shipmode", vShipMode); dgkpi.GridView.GridResponse.AdditionalProperties.Add("comments", vComments); dgkpi.GridView.GridResponse.AdditionalProperties.Add("otisapproved", vOtisApproved);
}
)