Mak,
I wanted to refer to the value of the bound field (by these codes below in code-behind) and then put the value as a parameter when performing 'Insert' on that gridview.
protected void btnInsert_clicked(object sender, EventArgs e)
{
BoundField title = (BoundField)Page.FindControl("title");
ds_job_det.InsertParameters.Clear();
ds_job_det.InsertParameters.Add("title", title.ToString());
...
}
Many many thanks Mak. By the way, how will the updatecommand action of that gridview trigger an event like the above one?
Further, suppose that the Gridview, when being updated, and it will trigger another event, which is specifically for the update, how can we know which row ID the current row is?
wmec
Contributor
6228 Points
3226 Posts
Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 04:45 AM|LINK
Hi,
I'm to refer to a boundfield that is one field among a gridview, in the code-behind
protected void btnInsert_clicked(object sender, EventArgs e)
{
BoundField title = (BoundField)Page.FindControl("title");
...
}
but I've got this error below. Any advice?
Error 1 Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.BoundField'
What's the problem to refer to the bound field?
HuaMin Chen
harieis
Participant
782 Points
242 Posts
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 04:49 AM|LINK
is the button inside/outside the gridview??
if inside u should use databound events/
Can u send the full code??
What is ur purpose??
pls say all things..
Harikrishnan.S
shashankmish...
Member
296 Points
60 Posts
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 04:50 AM|LINK
Are you using a MasterPage, if yes than look out the link:
http://www.west-wind.com/Weblog/posts/5127.aspx
--
Shashank
BeClasp Consulting
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 05:13 AM|LINK
Can you explain what you want to do here?
Contact me
wmec
Contributor
6228 Points
3226 Posts
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 08:17 AM|LINK
Thanks all.
Mak,
I wanted to refer to the value of the bound field (by these codes below in code-behind) and then put the value as a parameter when performing 'Insert' on that gridview.
protected void btnInsert_clicked(object sender, EventArgs e)
{
BoundField title = (BoundField)Page.FindControl("title");
ds_job_det.InsertParameters.Clear();
ds_job_det.InsertParameters.Add("title", title.ToString());
...
}
HuaMin Chen
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 08:24 AM|LINK
AWhich control has the boundfield ? GridView?
Contact me
wmec
Contributor
6228 Points
3226 Posts
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 08:48 AM|LINK
Yes
HuaMin Chen
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 08:55 AM|LINK
Then to get the data of bound fields do this way
for (int i = 0; i < GridView1.Rows.Count; i++) {
string boundfield1= GridView1.Rows(i).Cells(0).Text;
string boundfield2= GridView1.Rows(i).Cells(1).Text;
string boundfield3= GridView1.Rows(i).Cells(2).Text;
}
Contact me
wmec
Contributor
6228 Points
3226 Posts
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 09:19 AM|LINK
Many many thanks Mak. By the way, how will the updatecommand action of that gridview trigger an event like the above one?
Further, suppose that the Gridview, when being updated, and it will trigger another event, which is specifically for the update, how can we know which row ID the current row is?
HuaMin Chen
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Cannot convert type 'System.Web.UI.Control' to ...
May 20, 2009 09:41 AM|LINK
What does that mean?
Contact me