Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Please help me, I need a click on the button fires the b_click procedure and it's not working.
Here is my custom control with a gridview and a column added dynamically using a ITemplate class.


namespace NamespaceServerControlSearch
{
[ToolboxData("<{0}:ServerControlSearch runat="server">")]
public class ServerControlSearch : CompositeControl
{
private global::System.Web.UI.WebControls.GridView grid;


protected override void CreateChildControls()
{
Controls.Clear();

grid = new GridView();
grid.AutoGenerateColumns = true;
grid.ID = "grid";
grid.Width = Unit.Pixel(400);
grid.Height = Unit.Pixel(100);
grid.BorderStyle = BorderStyle.Solid;

DataColumn col = new DataColumn("xxx");
TemplateField bfield = new TemplateField();
bfield.HeaderTemplate = new GridViewTemplateSelect(ListItemType.Header, col.ColumnName);
bfield.ItemTemplate = new GridViewTemplateSelect(ListItemType.Item, col.ColumnName);
grid.Columns.Add(bfield);

DataSet ds = new DataSet();
using (SqlConnection conn = new SqlConnection("Data Source=(local); Initial Catalog=db; USER=sa; PASSWORD=xxx"))
{
SqlDataAdapter da = new SqlDataAdapter("select codigo, nombre from CAS_USERS cu where codigo like 'F37008%'", conn);
da.Fill(ds);
}

grid.DataSource = ds.Tables[0];
grid.DataBind();

}

protected override void Render(HtmlTextWriter o)
{
o.Write("
Posted
Updated 16-Dec-13 4:49am
v2
Comments
Sergey Alexandrovich Kryukov 16-Dec-13 10:29am    
When you say "GridView", the question is: which one? Do you think there is only one? Full type name, please.
—SA
Member 10204686 16-Dec-13 10:48am    
Sorry asp.net
global::System.Web.UI.WebControls.GridView

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900