Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid limitations?

Status
Not open for further replies.

mrobb

Programmer
Nov 29, 2001
9
0
0
US
I know that Microsoft is pushing developers to use the DataGrid server control rather than manually coding HTML tables. I've spent the past two days evaluating the DataGrid control and have had no luck finding a way to do the following tasks. Can anyone confirm whether or not these tasks are possible with the DataGrid control? If they're not, I'll be abandoning the DataGrid control and going back to the old, though a little more effort, way of doing things.
-----------------------------------------------------------

1. Create a column using <asp:templateColumn> control that lists radio buttons, and dynamically program the &quot;ID&quot; property of the radio button with a value from a database, (e.g., the key ID field from the database).

2. My datagrid returns a bit value from my database ('True' or 'False' text appears in datagrid). I want the datagrid to show text such as 'Enabled' for True values, and 'Disabled' for False values.

3. My datagrid returns a bit value from my database ('True or 'False' text appears in datagrid). I want the datagrid to show one image file for the True values, and another image for the False values.
 
it's all about the itemDataBound event.

Do a search on google, and read some articles... it's a great way to customize the output of your datagrid.

After some reading, if you still have more specific questions, then post back to this thread, and we can hash them out.

These things (and much, much more) are possible and not terribly difficult w/ the datagrid.

I was very reluctant to adopt it, myself, because I felt like I would be giving up a great deal of flexibility. But once you learn to use all the events available to you, there's really not much you can't do w/ it.

And if the datagrid just doesn't work (which it will in this case), there's always the datalist. And if not that, then the ultimately flexible repeater control. The amount of work increases as you step down levels, though, so try to stick with as high as you can and still get the results that you need.

:)
paul
penny1.gif
penny1.gif
 
Hi,
I had Tried Giving the same thing for CheckBox, First I tried data binding the Checked Property of the Box to the Boolean Field. But the First row value alone was Shown to all the records. I.e., if First of the Record is True then all the Values where True and the Vice Versa...

So Wrote a Code for this.. this might be a round about way but it works...

dg1.DataBind()
Dim dgitem As DataGridItem
Dim chkbox As System.Web.UI.WebControls.CheckBox

For Each dgitem In dg1.Items
chkbox = dgitem.Cells(0).Controls(1)
chkbox.Checked = IIf(dgitem.Cells(5).Text = &quot;True&quot;, True, False)
Next


Hope this Helps....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top