473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to replace values bound in datalist

Hi all!

I want to replace the values of QID in my datalist1 bound with the following
data:

Dim sqlStmnt As String = "Select QID, QUESTION from ENVIRONMENTAL_EXAM order by newid() "

Dim myda As SqlDataAdapter = New SqlDataAdapter(sqlStmnt, scon)
Dim ds As New DataSet

myda.Fill(ds, "Table")

DataList1.DataSource = ds
DataList1.DataBind()

'--code to replace the values of QID ????

'----------------------------------
My sqlcommand return random sets of records, as well as the QID. I want to
replace each QID with sequential values(1 to N), but i don't know how to do this
on datalist. The idea is just like replacing the values in a datagrid after databind. Please see below sample..
'-----------------------------------------------------------------------
Datagrid1.Databind()

Dim item, i, ctr As Integer
Dim temp as string

ctr = 0
item = datagrid1.Items.Count()

For i = 0 To item - 1

ctr = ctr + 1
datagrid1.Items(i).Cells(1).Text = ctr
Next i

'------------------------------------------------------

Can anyone tell me how to do this on datalist? Or if you could suggest more practical approach, please do...

Looking forward for your help. Thanks in advance...
Jan 29 '08 #1
2 1554
harshmaul
490 Expert 256MB
you can try this....

Create a PROTECTED INT

like this

Expand|Select|Wrap|Line Numbers
  1.     protected int increment = 0;
then in the "ITEMCREATED" event of the datalist write some code something like this....

Expand|Select|Wrap|Line Numbers
  1.     protected void MyList_ItemCreated(object sender, DataListItemEventArgs e)
  2.     {
  3.         increment ++;
  4.     }
Finally in the designer print out the value of the variable increment on each itemtemplate something like this....


Expand|Select|Wrap|Line Numbers
  1. <ItemTemplate>
  2. <%#increment %>
  3. </ItemTemplate>
NOTE: the #, and not an =

i hope that makes sense...
Jan 29 '08 #2
Hi sir!

Thanks for the idea.
I'm done with my project. I do replacement on dataset before binding into datalist.

I really do appreciate your help!...=)

you can try this....

Create a PROTECTED INT

like this

Expand|Select|Wrap|Line Numbers
  1.     protected int increment = 0;
then in the "ITEMCREATED" event of the datalist write some code something like this....

Expand|Select|Wrap|Line Numbers
  1.     protected void MyList_ItemCreated(object sender, DataListItemEventArgs e)
  2.     {
  3.         increment ++;
  4.     }
Finally in the designer print out the value of the variable increment on each itemtemplate something like this....


Expand|Select|Wrap|Line Numbers
  1. <ItemTemplate>
  2. <%#increment %>
  3. </ItemTemplate>
NOTE: the #, and not an =

i hope that makes sense...
Jan 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mark | last post by:
Hi, I have a datalist that contains a textbox as well as a dropdown list. For each single row in the datalist the associated dropdown list can have at least one value What I would like to be...
0
by: Beorn | last post by:
Does anybody have experience using a bound ListBox within a DataList? The DataList should repeat for a list of Categories, each category holds a list of components under that category. The User...
1
by: Bigtoga | last post by:
Okay - I'm going crazy here trying to figure out how to do this - here goes: I have a DataList populated by a DataReader. In the DataReader, a column is present called "IsInCategory". I want to...
4
by: krzysiek | last post by:
hello, i have several radiolists and checkboxlist that are generated dinamicly based on datasource. So frankly speaking i don't know names and number of that web controls cose they are always...
1
by: Gary Frank | last post by:
I added a couple of labels and a button to a Datalist control called "dlSignIn" by adding them to the Item template. The labels are bound to a dataset column. Program code gets executed in the...
1
by: Mike | last post by:
I have a Datalist control on my page that I have binded to a table of available categories. In the Item Template I have a CheckboxList control bound to the products available in each Category. I...
2
by: ASP Developer | last post by:
Is it possible to bind a datalist that is inside of a bound datalist? Any help would be greatly appreciated.
0
by: HP | last post by:
Hi there I have a datalist control with some bound controls in its Item Template and a gridview bound to one of those fields (residing also in Item Template). I've found out that when I click...
1
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.