unbound controls in GridView

Y

yoni

Hi,
I got a grid control, i bind it to a datatable, but it has some extra
fields, with textboxes, checkboxes, dropdowns etc (in a template
field) that are not bound. they are not auto-postback either. user
changes values in them, then clicks submit. anybody knows how i can
get the values in those controls, per each record? (ideally, i could
know which record's controls have been updated and get only to them.
then i have my own code to deal with those new values)

thanks
 
M

mike

I do something similar with my GridViews. In view mode, I just have a
representaton of the value. When I switch to Edit mode is when I want
to show my checkboxes and such.

To get values out of them you need to handle the GridView.RowUpdating
event. The code below (my GridView.RowUpdating event) finds the
txtCareerHi control in the selected GridView row and mirrors it in a
TextBox control stored in memory. On my form, the TextBox is a multi-
line TextBox and I want to preserve the vbCrLf characters. The funny
thing is that in view mode, I need to render them as HTML "<br />"
tags while in the TextBox, I need vbCrLf. I store the <br /> tags in
my database.

' converts vbCrLf to said:
tags are stored in the database
Dim career As TextBox
career =
CType(gridCareer.Rows(e.RowIndex).FindControl("txtCareerHi"), TextBox)

Dim strCareer As String
strCareer = career.Text.Replace(vbCrLf, "<br />")

e.NewValues.Add("career_hi", strCareer)

gridCareer.DataBind()


My problem is that the values I want for my RadioButtonLists and
DropDownLists are stored in my database. I need a value and text. How
can I bind the RadioButtonList with value and text properties? They
only exist when the row enters Edit mode.

Cheers
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top