DataGrid templateColumn

DataGrid templateColumn

Post by Roger James » Wed, 23 Oct 2002 17:17:42



Can someone please post some code (VB) which shows me how to add data
from a dataset column (eg. "http://abcnews.com") into a grid column.

I have tried using HyperLinkColumn and I have tried many things to try
and get it working properly in the code behind (as opposed to the aspx
file - Where should I do it anyways??)

Dim o As New HyperLinkColumn()
o.HeaderText = "Web Address"
o.DataNavigateUrlField = "my_url"
o.DataTextField = "org_web_address"
o.DataNavigateUrlFormatString = "http://{0}"

The problem is that if the database field has "http://"  in it, then I
get a grid column link with http://http://www.abcnews.com which is
stupid.  If I remove the http:// from the format above, then I get
localhost/myweb/WebControls/www.abcnews.com

You would think the hyperlink column could handle this.

Do I need to use a template column and if so, how do I do this in the
code behind?

Please help

Roger

 
 
 

DataGrid templateColumn

Post by Tusnu » Thu, 24 Oct 2002 01:23:29


This is going to be a little off topic from DataGrid TemplateColumn.

I think the easiest thing for you to do is to modify the data that you are
populating your DataGrid with.

Change the query in SQL or your DataSet to filter out the "http://"

SELECT REPLACE( my_url, 'http://', '') as 'my_url'
FROM myTable



Quote:> Can someone please post some code (VB) which shows me how to add data
> from a dataset column (eg. "http://abcnews.com") into a grid column.

> I have tried using HyperLinkColumn and I have tried many things to try
> and get it working properly in the code behind (as opposed to the aspx
> file - Where should I do it anyways??)

> Dim o As New HyperLinkColumn()
> o.HeaderText = "Web Address"
> o.DataNavigateUrlField = "my_url"
> o.DataTextField = "org_web_address"
> o.DataNavigateUrlFormatString = "http://{0}"

> The problem is that if the database field has "http://"  in it, then I
> get a grid column link with http://http://www.abcnews.com which is
> stupid.  If I remove the http:// from the format above, then I get
> localhost/myweb/WebControls/www.abcnews.com

> You would think the hyperlink column could handle this.

> Do I need to use a template column and if so, how do I do this in the
> code behind?

> Please help

> Roger


 
 
 

1. Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

I'm confused by what the current API is for Accessing the

All the documentation and tutorial articles say to do this:

private void DataGrid1_Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
    DataRow dr = dataSetInvoices1.Tables["Invoices"].NewRow();
    TextBox box1 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceNumber");
    dr["invoice_number"] = box1.Text;
    TextBox box2 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceDate");
    dr["invoice_date"] = DateTime.Parse(box2.Text);
    dataSetInvoices1.Tables["Invoices"].Rows[e.Item.ItemIndex].Delete();
    dataSetInvoices1.Tables["Invoices"].Rows.Add(dr);
    DataGrid1.DataBind();
    Session["Invoice"] = dataSetInvoices1;

But the found controls only contain the value of the Textboxes as delivered
to the client, not the newly typed values in the "EditItem" Textboxes.

What am I missing here? Is there a pre-step to get the datagrid to accept
the user's text and other control input, or do I need a different API than
e.Item.Cells[].FindControl("")?

2. Notes: multiple POPS and IMAP configuration

3. Datagrid TemplateColumn and Select list

4. set camera toolbar on by default?

5. DataGrid - TemplateColumn

6. DOS is *not* #1, Loon

7. DataGrid TemplateColumns

8. All you sysops with Zoom or Microcom deals Respond!

9. Using IF statement in DataGrid TemplateColumn

10. how to get access to a checkbox in a datagrid templatecolumn

11. Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

12. TemplateColumn databinding in DataGrid

13. Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.