| Author: Parul Rathore 10 Jan 2009 | Member Level: Silver | Rating:    Points: 6 |
Update below code according to ur need, This will solve ur problem definetly-- <asp:DataList ID="dtlResult" Width="905" DataKeyField="resultid" runat="server" RepeatColumns="1" RepeatDirection="Horizontal" onitemdatabound="dtlResult_ItemDataBound"> <ItemTemplate> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="60%"> <%# Eval("Title") %> </td> <td > <asp:DropDownList ID="cboBoard" Width="99%" runat="server"> </asp:DropDownList> </td> </tr> </table> </ItemTemplate> </asp:DataList>
protected void dtlResult_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DropDownList cboboard = (DropDownList)e.Item.FindControl("cboBoard"); if (cboboard != null) { FillCombo(cboboard, "select title,id from tbl_uni_board_master ", "id", "title");// user defined function to fill dropdownlist Int64 id = Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "resultid")); try { string strQuery = "select b.id from tbl_results r ,tbl_uni_board_master b where r.boardid=b.id and r.resultid=" + id; cboboard.SelectedValue = SqlHelper.ExecuteScalar(Connection.ConnectionString, CommandType.Text, strQuery).ToString(); // execute query to get id cboboard.Items.RemoveAt(0); } catch { } }
}
please mark the response
|