Reputation: 371
here I am trying to hide the column in the datagrid, the column is:
<asp:BoundField HeaderText="Transaction Category ID" DataField="TransactionCategoryID"
ItemStyle-CssClass="gridview_item_center" visible="false"/>
but the problem is, when I try to get the data (in javascript function below), while the datagrid column is hidden it acts like it doesn't exist, so the value returned is wrong, is there any alternate solution to just simply hide the column but the value is still acceptable?
the javascript (should it needed):
function ShowAddDialog(lnkTransactionID) {
if (lnkTransactionID != null) {
//alert("ID:" + $(lnkTransactionID)[0].innerHTML);
var td = lnkTransactionID.parentElement;
var transactionCategory = $(td.nextSibling)[0].innerHTML;
var transactionDesc = $(td.nextSibling.nextSibling.nextSibling)[0].innerHTML;
$("[id$='lblTransactionID']").text($(lnkTransactionID)[0].innerHTML);
$("[id$='hfTransactionID']").val($(lnkTransactionID)[0].innerHTML);
$("[id$='ddlTransactionCategoryInput']").val(transactionCategory);
$("[id$='txtTransactionDescInput']").val(transactionDesc);
}
$("#divDialog").dialog("open");
}
Upvotes: 0
Views: 406
Reputation: 613
When you set the visibility to false, it doesn't get rendered in HTML, hence the error.
Use a css class with display:none and see if it helps.
A sample css class would look like this:
.classHiddden
{display:none;}
Then assign this class to the control you want to hide.
Thanks,
Upvotes: 1