[NEWBIE] template change_text fires, but where is data?

B

Beemer Biker

It was hard enough to code up a drop down list template, now I cannot seem
to get the results of the change event fireing back. Properties for the
combobox template show that the name is:

Gridview1.Column13combo.ItemTemplate.DDL_ChangeImage

Problem is, DDL_ChangeImage does not seem to exist. It should have shown up
using "this.DDL_ChangeImage" All is see in intellisense is the
this.DDL_ChangeImage_TextChanged event. I cannot find "Column13combo"
defined anywhere using intellisense nor the control "DDL_ChangeImage"

I would have thought that the TextChanged event would have provided the
text for me. No such luck, "e" seems really plain and I have never figured
out what "sender" is good for. Maybe it can be cast to something useful??

...anyway i tried the following and googled a lot before posting here..

protected void DDL_ChangeImage_TextChanged(object sender, EventArgs e)
{
I tried the following which didnt work because gvr was null
GridViewRow gvr = GridView1.SelectedRow;
DropDownList ddl = (DropDownList)gvr.Cells[13].Controls[0];
Response.Write("new index is " + ddl.Text + "<br>");
}

the following had the same problem. it fired, but I have no idea how to get
the index value.

protected void DDL_ChangeImage_SelectedIndexChanged(object sender, EventArgs
e)
{
}

==========A SECOND QUESTION==========

why was SelectedRow null? Since I clicked on the combo box, the grid should
have known what row I was at. Doesnt GridView1.SelectedRow return the
current row object?
 
B

Beemer Biker

Solved problem why SelectedRow is null. It has not been set even on the
event "SelectedIndexChanged". Seems that templates are not like bound
controls. Read up on the problem here
http://geekswithblogs.net/azamsharp/archive/2006/09/15/91308.aspx

Here is final solution that updates the ImageField in one column based on
the combobox index of a template in another column

protected void DDL_ChangeImage_SelectedIndexChanged(object sender, EventArgs
e)
{
DropDownList ddl = (DropDownList) sender;
int iIndex = ddl.SelectedIndex;
Control senderControl = (Control) sender;
GridViewRow row = (GridViewRow)senderControl.NamingContainer;
Image iPhoto = (Image) row.Cells[1].Controls[0];
iPhoto.ImageUrl = "http://localhost/images/" + iIndex + ".jpg";
}

Beemer Biker said:
It was hard enough to code up a drop down list template, now I cannot seem
to get the results of the change event fireing back. Properties for the
combobox template show that the name is:

Gridview1.Column13combo.ItemTemplate.DDL_ChangeImage

Problem is, DDL_ChangeImage does not seem to exist. It should have shown
up using "this.DDL_ChangeImage" All is see in intellisense is the
this.DDL_ChangeImage_TextChanged event. I cannot find "Column13combo"
defined anywhere using intellisense nor the control "DDL_ChangeImage"

I would have thought that the TextChanged event would have provided the
text for me. No such luck, "e" seems really plain and I have never
figured out what "sender" is good for. Maybe it can be cast to something
useful??

..anyway i tried the following and googled a lot before posting here..

protected void DDL_ChangeImage_TextChanged(object sender, EventArgs e)
{
I tried the following which didnt work because gvr was null
GridViewRow gvr = GridView1.SelectedRow;
DropDownList ddl = (DropDownList)gvr.Cells[13].Controls[0];
Response.Write("new index is " + ddl.Text + "<br>");
}

the following had the same problem. it fired, but I have no idea how to
get the index value.

protected void DDL_ChangeImage_SelectedIndexChanged(object sender,
EventArgs e)
{
}

==========A SECOND QUESTION==========

why was SelectedRow null? Since I clicked on the combo box, the grid
should have known what row I was at. Doesnt GridView1.SelectedRow return
the current row object?


--
=======================================================================
Beemer Biker joestateson at grandecom dot net
http://TipsForTheComputingImpaired.com
http://ResearchRiders.org Ask about my 99'R1100RT
=======================================================================
 

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

Top