Including data from DropDownList in Gridview
I feel a little confused asking two questions pertaining to the same problem, but the first one answered a question that I believe is unrelated to a solution, so I leave it and outline what I am trying to accomplish with the hope that can someone help .Net noob.
What I need to do is create a field in my gridview that contains a link that passes two variables. One is fetched from the gridviews datasource and the other needs to be pulled from the textbox control outside of the gridview.
From what I've read so far, you cannot use hyperlinks to do this, as datanavigateurl fields cannot be configured to fetch anything other than the gridview datasource.
What I tried to do was create a template field that I called on the itemtemplate:
<a href="example.aspx?e=<%# Eval(ExampleList.SelectedItem.Value) %>">Test</a>
This returns with an error like this:
DataBinding: 'System.Data.DataRowView' does not contain a property with the value 'TestData'
Any hints to make this happen would be appreciated, as I said, I'm pretty new to .Net so please be careful. I tried to do my homework before posting this.
a source to share
How about placing a hyperlink server in a column of a GridView template as shown below.
<asp:Hyperlink id="hyperlink" runat="server" onDataBinding="hyperlink_DataBinding" text="Click ME" />
Then in your code, add this data binding event for the hyperlink.
protected void hyperlink_DataBinding(object sender, EventArgs e) {
HyperLink link = (HyperLink) sender;
string param1 = Eval("field").ToString();
string param2 = ExampleList.SelectedItem.Value;
link.NavigateUrl = "example.aspx?e=" + param1 + "&f=" + param2;
}
a source to share