473,796 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to replace values bound in datalist

4 New Member
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_E XAM order by newid() "

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

myda.Fill(ds, "Table")

DataList1.DataS ource = ds
DataList1.DataB ind()

'--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.Datab ind()

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).Te xt = 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 1575
harshmaul
490 Recognized Expert Contributor
you can try this....

Create a PROTECTED INT

like this

Expand|Select|Wrap|Line Numbers
  1.     protected int increment = 0;
then in the "ITEMCREATE D" 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
wolverine2512
4 New Member
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 "ITEMCREATE D" 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
2010
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 able to do is when a single update button is clicked the textbox value along with the associated dropdown value is printed for each row in the datalist. The number of rows in the datalist can vary. Here is my Datalist code
0
1292
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 wil select a component for each category (with an associated price....) and click update, the adjusted price (sum of all selelcted components) is show in the footer. Should be simple. The code is chopped and changed a little for...
1
2322
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 have a checkbox bound to that column (bit in SQL Server). I have tried everything and can't see a way to do this without createing an event handler for DataBind() of the CheckBox control. Surely there has to be a better way (and please don't...
4
6551
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 different. How can i retreive selected values from those controls ?
1
11953
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 dlSignIn_SelectedIndexChanged subroutine when I click the button in the datalist. And the dlSignIn.SelectedIndex property has the correct index for the Datalist row that was selected. Now I would like to access the values in the labels of that...
1
2200
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 need to pull out of the page which products the user has selected. I have bound the products to the CheckboxList control in the ItemDataBound event for the Datalist. How can I extract what checkboxes have been selected inside the Datalist?
2
2059
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
1470
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 Edit on the gridview (same happens when editing other gridview which is outside the datalist) all datalist bound fields (except the gridview) disappear, and they don't appear after submitting GV changes - they do only after changing value of some
1
7944
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 the values that have been checked when the user submits the form. This code works as far as presentation goes but I can't seem to retrieve the checked values in the various checkboxlists that have been generated on the datalist's OnItemDataBound ...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10465
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10242
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.