How to re-assign a value in a datalist.



  • 1. Help on HTTPModules
    Hi, I need to log all info,of whoever logs into my application and what all he clicks...and which all methods are executed and what parameters are passed. Is there any way I can log info at a single place....a common place and so that I dont need to put code in all methods and in all pages... any sample apps/code for this? -- Arvind
  • 2. AJAX kit available for
    Is there a good AJAX development kit for I'm interested in adding some asynchronous javascript XML calls to my application. It would be nice if there were good libraries already ready for me to use.

How to re-assign a value in a datalist.

Postby craigkenisston » Sun, 27 Feb 2005 04:53:44 GMT


In a datalist I'm displaying data comming from a SQL Server stored
procedure that contains null values in numeric values. Since the stored
is already used in other applications I can't change it.

So, I need to catch this nulls and convert them to zeroes so, they
display in the TD on the table I have in the datalist.

I have this method :

private void Repeater1_ItemDataBound(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
double d01;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
	if (DataBinder.Eval(e.Item.DataItem, "mypossiblenullfield") == null)
		// what do I do here ?

It seems this code is being hitted, but I don't know how to change or
how to access the value of the DataItem.

Thanks in advance,

Re: How to re-assign a value in a datalist.

Postby Jc Morin » Sun, 27 Feb 2005 08:37:04 GMT


Maybe you can iterated over your results before datasource/databind and
replace null value with 0 or any changed needed.

Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada

Similar Threads:

1.Reassign value to private

Hi Can some one please tell me how I re assign a value to a private variable 
with a querystring!

I want to do something like this!

Private rowID As Integer = request.querystring(id)

However this doesn't work!

Would really appritiate anyhelp!


.. Current Code ..
 Private rowID As Integer = "1"

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load

        'Get Text for Editor
        If Not Page.IsPostBack Then
            FreeTextBox1.Text = GetDocument()
        End If

    End Sub 'Page_Load 
    Public Sub Button_Click(ByVal sender As Object, ByVal e As 
    End Sub 'Button_Click 

    Private Function GetDocument() As String
        Dim ds As DataSet = GetDataSet(("SELECT * FROM tblPageContent WHERE 
pageID=" + rowID.ToString()))
        Dim table As DataTable = ds.Tables(0)
        Dim row As DataRow = table.Rows(0)
        Dim doc As String = row("content").ToString()
        Return doc
    End Function 'GetDocument 

2.Value in DataTable not changing when new value assigned

VS2005, C#, Win CE 5.

I have a very strange problem which must have a simple answer. I am new to 

I am reading a simple XML file into a DataSet (1 table, 5 rows, 2 string 
fields per row).
This works ok, I can see the data in the debugger QuickWatch window.

I want to change the value of a string field in the DataSet table currently 
set to "123":

MyDataTable.Rows[2].ItemArray[1] = "xyz"

It does not change! It is still "123" immediately after this line and no 
The RowState before and after this line is "Unchanged"

How can this be?
The DataSet is not read only (and I assume if it was, then an exception 
would be generated when trying to change the value).

Any help extremely welcome.


3.Error assigning value to WMP URL attribute value...

Using VB.NET 2003,
I get the following error when I assign a value to my WMP player's URL 
    player.URL = "C:\Audio\..\Content_IRB\Audio\Audio_IRB.0.wav"

Err Object contents
    Description: "Exception from HRESULT: 0xC00D132B."
    Erl: 0
    HelpContext: 0
    HelpFile: ""
    LastDllError: 0
    Number: -1072884949
    Source: "Interop.WMPLib"

Note that the above URL contains a relative path "..\" in the address... it 
seems taht this may contribute to the problem because URL's w/no relative 
addresses work fine. Problem is that I need to use a relative path in this 

Is this a known bug in the WMP? Anyone have any background or further 

Thanks for your atention to this matter...

4.Cannot dynamically assign a BackColor to a datalist

I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style

<HeaderStyle BackColor="<%= ssponcont %>"> </HeaderStyle>

...doesnot work as a Parser error renders: Content ('<HeaderStyle
BackColor=') does not match any properties within a
'System.Web.UI.WebControls.DataList', make sure it is well-formed

5.Setting up a datalist control - Item_DataBound for a datalist in a datalist

I have a multi-level datalist setup:

I have columns explicitly defined for the grid in the html.
Sometimes, On the initial Load() of the Page, I want to add extra columns to 
the datagrid - for all records.

I tried getting a reference to the datagrid like this:
foreach(Control ctrl in this.DataList1.Controls)
    if (ctrl.ID == "DataList2")
        DataList2 = (DataList) ctrl;

DataGrid MyGrid;

foreach(Control ctrl in dlstClasses.Controls)
    if (ctrl.ID == "MyGrid")
        MyGrid= (DataGrid) ctrl;

But the inner DataList2 isn't found in the controls set of DataList1, and so 
MyGrid isn't found inside DataList2, of course.

So how do I make those changes to the datagrid?  Help?

6. basic: should you reassign parameters, or use them without renaming/reassigning?

7. problem assigning value to struct member in for each

8. Problem assigning selectedItem.Value to a dropdownlist filled with OnItemDataBound

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 68 guest