Hi there,
Bellow you can see a simple example that is using a GridView where each row has a cell with a dropdown item.
Each time you click a cell from the GridView (except the cells with the dropdown inside) you will get a message with the current dropdown value from the selected row.
I hope this will help you!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Dummy test</title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#usersGridView td").click(function () {
if ($(this).find("select").length) {
return;
}
else {
var selectedRow = $(this).parent();
var selectedOptionValue = $(selectedRow).find("select option:selected").val();
alert("The selected row has rate: " +selectedOptionValue);
}
});
});
</script>
</head>
<body>
<form id="myForm" runat="server">
<asp:SqlDataSource runat="server" ID="MyDataSouce"
ConnectionString="Data Source=localhost;Initial Catalog=Users;Integrated Security=True;"
DataSourceMode = "DataReader"
SelectCommand = "select [Name], [Age] from [Users]">
</asp:SqlDataSource>
<asp:GridView ID="usersGridView"
Runat="server"
DataSourceID="MyDataSouce"
AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField = "Name" HeaderText = "Name"/>
<asp:BoundField DataField = "Age" HeaderText = "Age" />
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
<select>
<option value="10">10%</option>
<option value="20">20%</option>
<option value="30">30%</option>
<option value="40">40%</option>
</select>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>