I have a following string :
for(#some conditions){
##
result += "<tr><td>" + dc + "</td><td>" + al + "</td><tr>";
}
Now, i want to show the load the vlaue of dc and al in my HTML input text area using the aspx:grid.
For example the value of result is:
result = <tr><td>1111</td><td>23</td><td><tr><td>22222</td><td>43</td><tr>
Now i want to show the data in the following format using grid
dc al
1111 23
222222 43
For now, I am filling the text area using the following commands.
<script type = "text/javascript">
function submit_a()
{
$.post("../AllocationValidator.aspx", { "data": escape(validatorXML), "scenarioID": scenarioID }, function (result) {
alert("Data Saved!");
$("#allocations").empty();
$("#allocations").html(result);
BodyLoad();
});
}
</script>
<div id = "allocations" style = "width: 650px; padding: 10px; border: 1px solid black;height: 150px; overflow:scroll;"></div>
My question is how to implement the asp:grid to display the data ?
If you simply want to display your retrieved data in a GridView control. You can either bind a data source to the control or add columns and rows programmatically.
You can bind any data sources that implement the IListSource or IList interface. This means that you cannot bind your
resultstring directly, as noted in your question title. You have to store your retrieved data in a compatible data structure like for example a List to bind it as the data source.To use databinding, you could save your
dcandalin a dictionary-like data structure. Assuming that you only want to display two columns of data.The corresponding grid would be
If you are using a foreach to generate your
resultstring, than you should look at the possibility to use the object in the foreach statement as your data source.