Hi,
We are using RadGrid with ASP.NET. My grid has templated column with textbox. When the page loads, I am populating Templated column Textbox with the amount that comes from database. Not all rows will have amount. For example, if my grid has 10 rows, only 3 rows may have amount. So, when the page load on client side I have routine that checks for amount in textbox. If it is empty, then hides the row like this:
function GridCreated(sender, eventArgs) {
//loop thru grid rows and hide the row
var inputElem = MasterTable.get_dataItems()[i].findElement("txtBoxAmount");
if (inputElem.value > 0)
MasterTable.get_dataItems()[i].set_visible(true);
else
MasterTable.get_dataItems()[i].set_visible(false);
}
This code is working fine and hiding row. After all work is done, when the user clicks on 'Submit' button,
Then in my routine on server side, I need to check for visibility property and then get the amounts like this:
foreach (GridDataItem row in rgdAccounts.Items)
{
if (row.Visible)
{//Account is part of the selected template (row is visible).
string value = ((TextBox)row.FindControl("txtBoxAmount")).Text;
if (value == "")
value = "0.00";
if (value != "0.00")
//Get the amount
}
}
This check for visibility is alwasy true, even though rows are hidden. So, from this what I understand is that
if rows are hidden on clientside using client side logic, when page gets posted, that won't be taken into
considertation on server side.
I am not using 'NEED Datasource' event for binding, because for our
architecture, it will not suite to use it. So, I am binding the grid when ever is required.
Please let me know how to take care of this situation.
Thanks,
Prathiba.