Y
yousuf
I have a dataList that pulls from a database table - Im trying to do
the normal Edit, Update, Delete, Cancel - on it.
when I put the following inside a user control - .ascx file it dosn't
work, but when I leave it in the Page, it works fine
<script language="C#" runat="server">
void populateList(){
//prepare data adapter, connect string etc..
DataSet ds = new DataSet();
da.Fill(ds, "PROPERTY");
PropertyList.DataSource = ds.Tables["PROPERTY"].DefaultView;
PropertyList.DataBind();
}
void Page_Load(Object s, EventArgs e){
if(!Page.IsPostBack){
populateList();
}
}
void Delete_Listing(Object Src, DataListCommandEventArgs e){
Response.Write("Delete");
populateList();
}
void Edit_Listing(Object Src, DataListCommandEventArgs e){
PropertyList.EditItemIndex = (int)e.Item.ItemIndex;
populateList();
}
void Cancel_Listing(Object Src, DataListCommandEventArgs e){
PropertyList.EditItemIndex = -1;
populateList();
}
void Update_Listing(Object Src, DataListCommandEventArgs e){
String updateS =
((DropDownList)e.Item.FindControl("editStatusList")).SelectedItem.Value;
Response.Write(updateS+"!");
populateList();
}
</script>
- My datalist displays and all the commands are set up correctly -
If I don't call populateList everytime on Page_Load - the DataList
event commands dont seem to work at all - and If I do call it
everytime, this causes a problem with the edit command - I refill the
list and all the edit values go back to thier orginal values and I
can't maintain the viewstate. I have enabled the viewstate and
autoeventwireup in the @control in the .ascx file
any help would be appreciated
the normal Edit, Update, Delete, Cancel - on it.
when I put the following inside a user control - .ascx file it dosn't
work, but when I leave it in the Page, it works fine
<script language="C#" runat="server">
void populateList(){
//prepare data adapter, connect string etc..
DataSet ds = new DataSet();
da.Fill(ds, "PROPERTY");
PropertyList.DataSource = ds.Tables["PROPERTY"].DefaultView;
PropertyList.DataBind();
}
void Page_Load(Object s, EventArgs e){
if(!Page.IsPostBack){
populateList();
}
}
void Delete_Listing(Object Src, DataListCommandEventArgs e){
Response.Write("Delete");
populateList();
}
void Edit_Listing(Object Src, DataListCommandEventArgs e){
PropertyList.EditItemIndex = (int)e.Item.ItemIndex;
populateList();
}
void Cancel_Listing(Object Src, DataListCommandEventArgs e){
PropertyList.EditItemIndex = -1;
populateList();
}
void Update_Listing(Object Src, DataListCommandEventArgs e){
String updateS =
((DropDownList)e.Item.FindControl("editStatusList")).SelectedItem.Value;
Response.Write(updateS+"!");
populateList();
}
</script>
- My datalist displays and all the commands are set up correctly -
If I don't call populateList everytime on Page_Load - the DataList
event commands dont seem to work at all - and If I do call it
everytime, this causes a problem with the edit command - I refill the
list and all the edit values go back to thier orginal values and I
can't maintain the viewstate. I have enabled the viewstate and
autoeventwireup in the @control in the .ascx file
any help would be appreciated