G
Guest
Ok whats wrong with my toolbar? When I debug I don't get an error message
and the databinding is working correctly but the toolbar itself and the
<iewc:ToolbarDropDownlist /> control isn't showing up all that is returned to
the web page is the buttons text and the contents of the DropDownlist. What
am I doing wrong here? Below is the control I typed in and below that is the
code behind.
<iewc:toolbar id="Toolbar1" runat="server">
<iewc:ToolbarTextBox Width="100px" TabIndex="1"
ID="MName"></iewc:ToolbarTextBox>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarButton Text="Add" ID="Add"
TabIndex="2"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarDropDownList AutoPostBack="True" ID="Select"
runat="server"></iewc:ToolbarDropDownList>
<iewc:ToolbarButton Text="Edit" ID="Edit"></iewc:ToolbarButton>
<iewc:ToolbarButton Text="Delete"
ID="Delete"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarTextBox ID="SecName"></iewc:ToolbarTextBox>
<iewc:ToolbarButton ID="SecAdd" Text="Add"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarDropDownList AutoPostBack="True" ID="DDLSection"
runat="server"></iewc:ToolbarDropDownList>
<iewc:ToolbarButton Text="Edit"
ID="EditSec"></iewc:ToolbarButton>
<iewc:ToolbarButton Text="Delete"
ID="DeleteSection"></iewc:ToolbarButton>
</iewc:toolbar>
Codebehind:
protected System.Web.UI.WebControls.DataGrid dgCMS1;
// Instances of the Toolbar control.
protected Microsoft.Web.UI.WebControls.Toolbar Toolbar1;
protected Microsoft.Web.UI.WebControls.ToolbarTextBox MName;
protected Microsoft.Web.UI.WebControls.ToolbarButton Add;
protected Microsoft.Web.UI.WebControls.ToolbarDropDownList Select;
protected Microsoft.Web.UI.WebControls.ToolbarButton Edit;
protected Microsoft.Web.UI.WebControls.ToolbarButton Delete;
protected Microsoft.Web.UI.WebControls.ToolbarTextBox SecName;
protected Microsoft.Web.UI.WebControls.ToolbarButton SecAdd;
protected Microsoft.Web.UI.WebControls.ToolbarDropDownList DDLSection;
protected Microsoft.Web.UI.WebControls.ToolbarButton EditSec;
protected Microsoft.Web.UI.WebControls.ToolbarButton DeleteSection;
// Database connection and access.
protected System.Data.SqlClient.SqlConnection clubconn;
protected System.Data.SqlClient.SqlDataAdapter clubadapt;
protected System.Data.DataSet dsClub;
// DataBase Connection String.
string strclubconn=ConfigurationSettings.AppSettings["ConnectionString"];
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
public void BindData()
{
string strDDLMenu="SELECT Menu_tbl.* FROM Menu_tbl";
string strDDLSection="SELECT Section_Tbl.* FROM Section_Tbl";
string strDDLSectionData="SELECT SectionData.* FROM SectionData";
string strDDLimg_tbl="SELECT img_tbl.* FROM img_tbl";
clubconn=new SqlConnection(strclubconn);
dsClub=new DataSet();
clubadapt=new SqlDataAdapter(strDDLMenu,clubconn);
clubadapt.Fill(dsClub,"DDLMenu");
clubadapt.SelectCommand=new SqlCommand(strDDLSection,clubconn);
clubadapt.Fill(dsClub,"DDLSection");
clubadapt.SelectCommand=new SqlCommand(strDDLSectionData,clubconn);
clubadapt.Fill(dsClub,"DDLSectionData");
clubadapt.SelectCommand=new SqlCommand(strDDLimg_tbl,clubconn);
clubadapt.Fill(dsClub,"img_tbl");
clubconn.Close();
dsClub.Relations.Add("Menu_Section",
dsClub.Tables["DDLMenu"].Columns["MenuID"],
dsClub.Tables["DDLSection"].Columns["MenuID"],false);
dsClub.Relations[0].Nested=true;
dsClub.Relations.Add("Section_IMG",
dsClub.Tables["DDLSection"].Columns["SectionID"],
dsClub.Tables["img_tbl"].Columns["SectionID"],false);
dsClub.Relations[1].Nested=true;
dsClub.Relations.Add("Section_SectionData",
dsClub.Tables["DDLSection"].Columns["SectionID"],
dsClub.Tables["DDLSectionData"].Columns["SectionID"],false);
dsClub.Relations[1].Nested=true;
Select.DataSource=dsClub;
Select.DataMember="DDLMenu";
Select.DataTextField="MenuName";
Select.DataValueField="MenuID";
Select.DataBind();
DDLSection.DataSource=GetChildRelation(dsClub,"Menu_Section");
DDLSection.DataMember="DDLSection";
DDLSection.DataTextField="SectionTitle";
DDLSection.DataValueField="SectionID";
DDLSection.DataBind();
}
protected DataView GetChildRelation(object dataItem, string relation)
{
DataRowView drv=dataItem as DataRowView;
if(drv != null)
{
return drv.CreateChildView(relation);
}
else
{
return null;
}
}
and the databinding is working correctly but the toolbar itself and the
<iewc:ToolbarDropDownlist /> control isn't showing up all that is returned to
the web page is the buttons text and the contents of the DropDownlist. What
am I doing wrong here? Below is the control I typed in and below that is the
code behind.
<iewc:toolbar id="Toolbar1" runat="server">
<iewc:ToolbarTextBox Width="100px" TabIndex="1"
ID="MName"></iewc:ToolbarTextBox>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarButton Text="Add" ID="Add"
TabIndex="2"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarDropDownList AutoPostBack="True" ID="Select"
runat="server"></iewc:ToolbarDropDownList>
<iewc:ToolbarButton Text="Edit" ID="Edit"></iewc:ToolbarButton>
<iewc:ToolbarButton Text="Delete"
ID="Delete"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarTextBox ID="SecName"></iewc:ToolbarTextBox>
<iewc:ToolbarButton ID="SecAdd" Text="Add"></iewc:ToolbarButton>
<iewc:ToolbarSeparator></iewc:ToolbarSeparator>
<iewc:ToolbarDropDownList AutoPostBack="True" ID="DDLSection"
runat="server"></iewc:ToolbarDropDownList>
<iewc:ToolbarButton Text="Edit"
ID="EditSec"></iewc:ToolbarButton>
<iewc:ToolbarButton Text="Delete"
ID="DeleteSection"></iewc:ToolbarButton>
</iewc:toolbar>
Codebehind:
protected System.Web.UI.WebControls.DataGrid dgCMS1;
// Instances of the Toolbar control.
protected Microsoft.Web.UI.WebControls.Toolbar Toolbar1;
protected Microsoft.Web.UI.WebControls.ToolbarTextBox MName;
protected Microsoft.Web.UI.WebControls.ToolbarButton Add;
protected Microsoft.Web.UI.WebControls.ToolbarDropDownList Select;
protected Microsoft.Web.UI.WebControls.ToolbarButton Edit;
protected Microsoft.Web.UI.WebControls.ToolbarButton Delete;
protected Microsoft.Web.UI.WebControls.ToolbarTextBox SecName;
protected Microsoft.Web.UI.WebControls.ToolbarButton SecAdd;
protected Microsoft.Web.UI.WebControls.ToolbarDropDownList DDLSection;
protected Microsoft.Web.UI.WebControls.ToolbarButton EditSec;
protected Microsoft.Web.UI.WebControls.ToolbarButton DeleteSection;
// Database connection and access.
protected System.Data.SqlClient.SqlConnection clubconn;
protected System.Data.SqlClient.SqlDataAdapter clubadapt;
protected System.Data.DataSet dsClub;
// DataBase Connection String.
string strclubconn=ConfigurationSettings.AppSettings["ConnectionString"];
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
public void BindData()
{
string strDDLMenu="SELECT Menu_tbl.* FROM Menu_tbl";
string strDDLSection="SELECT Section_Tbl.* FROM Section_Tbl";
string strDDLSectionData="SELECT SectionData.* FROM SectionData";
string strDDLimg_tbl="SELECT img_tbl.* FROM img_tbl";
clubconn=new SqlConnection(strclubconn);
dsClub=new DataSet();
clubadapt=new SqlDataAdapter(strDDLMenu,clubconn);
clubadapt.Fill(dsClub,"DDLMenu");
clubadapt.SelectCommand=new SqlCommand(strDDLSection,clubconn);
clubadapt.Fill(dsClub,"DDLSection");
clubadapt.SelectCommand=new SqlCommand(strDDLSectionData,clubconn);
clubadapt.Fill(dsClub,"DDLSectionData");
clubadapt.SelectCommand=new SqlCommand(strDDLimg_tbl,clubconn);
clubadapt.Fill(dsClub,"img_tbl");
clubconn.Close();
dsClub.Relations.Add("Menu_Section",
dsClub.Tables["DDLMenu"].Columns["MenuID"],
dsClub.Tables["DDLSection"].Columns["MenuID"],false);
dsClub.Relations[0].Nested=true;
dsClub.Relations.Add("Section_IMG",
dsClub.Tables["DDLSection"].Columns["SectionID"],
dsClub.Tables["img_tbl"].Columns["SectionID"],false);
dsClub.Relations[1].Nested=true;
dsClub.Relations.Add("Section_SectionData",
dsClub.Tables["DDLSection"].Columns["SectionID"],
dsClub.Tables["DDLSectionData"].Columns["SectionID"],false);
dsClub.Relations[1].Nested=true;
Select.DataSource=dsClub;
Select.DataMember="DDLMenu";
Select.DataTextField="MenuName";
Select.DataValueField="MenuID";
Select.DataBind();
DDLSection.DataSource=GetChildRelation(dsClub,"Menu_Section");
DDLSection.DataMember="DDLSection";
DDLSection.DataTextField="SectionTitle";
DDLSection.DataValueField="SectionID";
DDLSection.DataBind();
}
protected DataView GetChildRelation(object dataItem, string relation)
{
DataRowView drv=dataItem as DataRowView;
if(drv != null)
{
return drv.CreateChildView(relation);
}
else
{
return null;
}
}