473,382 Members | 1,407 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,382 software developers and data experts.

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(hidden)

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(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if((e.Item.ItemType==System.Web.UI.WebControls.Lis tItemType.AlternatingItem)||(e.Item.ItemType==List ItemType.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 + "LinkUserConfirm.ascx&user_id=" +

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

Nov 18 '05 #1
0 998

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

Similar topics

4
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...
2
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. ...
2
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,...
1
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...
1
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 ...
3
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...
1
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...
6
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.