Hello,
I have a grid that contains 3 fields: CityID, BranchID and Edit link.
When i click on the edit link, a web user control page "addFacilty.ascx" is displayed with the right edited items.
"addFacilty.ascx" include 2 dropdown lists ddlCity and ddlBranch and 2 textboxes cityid and branchid
I want that the dropdownlists contain as result:
1-ddlcity: the city having id: cityid.text.tostring()
2-ddlbranch: the branch having id : branchid.text.tostring();
Note that cityid and branchid are two textboxes with Text value is bind to grid. so it is automaically filled.
My problem now is that when i click on edit link of the grid. cityid and branchid of the webUser control page displays the right item. but when i want to use their values, cityid and branchid are treated as if they are empty.
below is the code of "addFacilty.ascx":
<asp:DropDownList ID="ddlCity" runat="server" DataSourceID="tblCity" DataTextField="city" DataValueField="cityID" AutoPostBack="true" SelectedValueField='<%#DataBinder.Eval( Container, "DataItem.cityID") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="tblCity" runat="server" ConnectionString="<% $ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="select cityID,city from viewCityAdmin"></asp:SqlDataSource>
<asp:DropDownList ID="ddlBranch" runat="server" DataSourceID="tblBranch"
DataTextField="Branch" DataValueField="BranchID">
</asp:DropDownList>
<asp:SqlDataSource ID="tblBranch" runat="server" ConnectionString="<%$ ConnectionStrings:SmartBookingEngineConn %>" SelectCommand="SELECT [BranchID],[Branch] FROM [tblBranch] WHERE ([CityID]=@cityID)">
<SelectParameters>
<asp:ControlParameter Name="cityID" ControlID="ddlCity" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<telerik:RadTextBox ID="cityid" runat="server" Height="28px" Visible="true" Text='<%# DataBinder.Eval( Container, "DataItem.cityID" ) %>' >
</telerik:RadTextBox>
<telerik:RadTextBox ID="branchid" runat="server" Height="28px" Visible="true" Text='<%# DataBinder.Eval( Container, "DataItem.BranchID")%>' AutoPostBack="true">
</telerik:RadTextBox>
***addFacilty.ascx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (cityid.Text.ToString() != "" && branchid.Text.ToString() !=""){
string selectedIDCity = cityid.Text.ToString();
tblCity.SelectCommand = "Select * from viewCityAdmin where cityID=@cityid";
tblCity.SelectParameters.Clear();
tblCity.SelectParameters.Add("cityid", selectedIDCity);
tblCity.DataBind();
string selectedIDBranch = branchid.Text.ToString();
tblBranch.SelectCommand = "Select * from tblBranch where BranchID=@branchid";
tblBranch.SelectParameters.Clear();
tblBranch.SelectParameters.Add("branchid", selectedIDBranch);
tblBranch.DataBind();
}
}
thank you in advance.