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

Home Posts Topics Members FAQ

Cannot access current datasource row for ds bound to datagrid

Hi,

I am trying to create a DataGrid that has a hyperlink in column 1.
Because of design reasons, the grid will auto generate columns and a
repeater will not work.
this output of the grid after databinding will look like this:
ID(hidden)~Name ~isLinked(hidde n)

In the Name column, I want to add a link below the name

In the ItemCreated event handler, I am creating a LiteralControl with
varying text depending on the value of the isLinked column and adding it to
the e.Item.Cells[1].Controls collection.

My problem is that I cannot access the value of any column, it is always
blank.

Thank you for any thoughts on fixing this problem.
-Keith
=============== =============== =============== ========
Sample eventhandler code:
=============== =============== =============== ========
private void DataGridResults _ItemCreated(ob ject sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{

if((e.Item.Item Type==System.We b.UI.WebControl s.ListItemType. AlternatingItem )||(e.Item.Item Type==ListItemT ype.Item))
{
string url="~/Directory/Controls/";
LiteralControl litctrl=new LiteralControl( );

if (e.Item.Cells[2]=="1")
litctrl.Text="< br>Already linked";
else
litctrl.Text="< br><a href='" + url + "LinkUserConfir m.ascx&user_id= " +

e.Item.Cells[0].Text + "'>Create Link</a>";
e.Item.Cells[1].Controls.Add(l itctrl);
}
}

Nov 18 '05 #1
0 1019

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15194
by: Steve | last post by:
Visual Studio 2003 .Net / C# I have a datagrid, which is bound to a dataset at runtime when my page loads. When the user double clicks a row, I need to find out which row they have selected so I can pass the key value onto another page, which is showing me more details for the selected row. So in the double click event of the datagrid I have this code: DataRow CurrentRow = dsJobList.Tables.Rows;
2
2351
by: Steve | last post by:
I'm in a weird situation where I'm using ComboBox's in a DataGrid. When the ComboBox selection changes, I'm currently storing the SelectedValue object into the DataSource of the DataGrid cell. This is not what I want. I want to bind a string to the datagrid, then bind the string and value of a lookup table to the combo box. When the combobox lookup is changed, I wanted to store the value in a different, unbound property of the bound...
2
2114
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns, ID and VALUE. I would like to create a templated column in the datagrid that is bound to the VALUE column of the datasource.
1
1088
by: Richard K Bethell | last post by:
I have a page that does some complex calculations in order to serve up a datatable that is then bound to a datagrid. I want to add sort to this datagrid. Now I know that to prevent a recalc, I could throw the DataTable in the viewstate and rebind at every hit. However, I am wondering if I have this available as an option - can I assign a DataTable the value of the ..DataSource property of the datagrid? It would lighten the burden on...
1
1301
by: Raterus | last post by:
Hi, I'm using a datagrid, and the sub ItemDataBound to customize output of my datagrid when it is bound. Is the only way I can access the data in my datasource is to use DataBinder.Eval(e.Item.DataItem, "myFieldName") It just seems to be a little clunky to have to use this for every varible in my datasource, even more when using "option strict" you have to cast the
3
3408
by: Tracey | last post by:
sorry I post this problem again. I have to stop my work to fix the problem. I'm doing a multi form application(Not a MDI one). My startup form say Form1 has a datagrid say datagrid1, when I click a grid item in datagrid1, I wanna show form2. In my code, I achieved that with: Public class Form1 Inherits System.Windows.Forms.Form
1
1745
by: Sean | last post by:
What is the best way to access the Underlying data of a DataGrid. I have two SQL tables joined and display some data from both, but I want to be able to on clicking of a row bring up a form that displays all the data. I can come up with some round about ways of doing it, but is there a property of the DataGrid that will make it easier and quicker to do? Thanks.
6
2006
by: Becker | last post by:
Very simple, I have a datagrid on a windows form. I load some rows in it. I click a column header and it sorts ascending. I click it again it sorts descending. This is great, but what I want to do is after the sort, I want to know what row is now the "selected" row. I want to do this so I can update some stuff on the form that correlates to this row. This does not seem so easy...please advise. Thanks, Ben
6
1027
by: john andrew | last post by:
-- hello I have VB.net standard. I thought this version has no data access but I have data controls . Do these things work with standard? Can i connect to a access database? I tried OLEadapter1 and a datagrid but nothing happens when i click on datasource property like VB6...i dont know, can anyone help please.
0
9529
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,...
1
10176
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
10013
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
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
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
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2927
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.