Hi,
really really hoping someone can help with this , by modifying the my code to return values to my GridView's templated column containg a dropdownlist.
I am trying to present a list of questions each of which can have different Answer types.
For example some questions can be answered with Yes and No and some can answered with be Yes, No, Not applicable, Exceeds.
To handle this I have 3 tables..
tblQuestion (QuestionID, QuestionText)
tblAnswer (AnswerID,Answertext)
tblAllowedAnswer (QuestionID,AnswerID)
I have a grid view that returns the values from tblQuestion(select * from tblquestion)
I added a templated field to the Gridview which contaisn a dropdown list , I now want to bind this dropdownlist to the allowable answers for each question ID (the QuestionID from that row of the GridView)
i think i need an event handler for RowDataBound as suggested by Azamsharp in his articles on GridViewGuy.com but I don't know how to write the event handler
Any idea of the code I would need to add to GridView1_RowDataBound to return the relevant values from tblAllowedAnswer to the templated fields dropdownlist
Attached is the aspx page source, Any ideas are very much appreciated.
aspx page....
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default8.aspx.cs" Inherits="Default8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label id="Label1" runat="server" Text="Name" Font-Bold="True" Width="107px"></asp:Label>
<asp:TextBox id="TextBox1" runat="server" Width="77px" Height="12px"></asp:TextBox>
<br />
</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" Width="80%">
<Columns>
<asp:BoundField DataField="QID" HeaderText="QID" InsertVisible="False" ReadOnly="True"
SortExpression="QID" />
<asp:BoundField DataField="Qtext" HeaderText="Qtext" SortExpression="Qtext" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BackColor="Yellow" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CPL_CallCentreConnectionString %>"
SelectCommand="SELECT * FROM [tbl1Q]"></asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CPL_CallCentreConnectionString %>"
SelectCommand="SELECT * FROM [tbl1Q]"></asp:SqlDataSource>
<br />
<asp:Button ID="Button4" runat="server" Text="submit" OnClick="Button4_Click" /><br />
</form>
</body>
</html>