GridView on MultiView / View with MenuItems to change Views - the problem
-
Thanks to Abisodun and Mike for answering my previous post. Both of the answers was directed to the 2nd part of my question. On the first part, I still need help. So - here's it again: I am using MultiView / View controls which change by MenuItem clicks. Each view has a GridView on it with Edit and Insert features. The problem is: when the edit button is clicked, the GridView disappears and you need to click on the MenuItem again to see it (it happens evrytime you click edit, update, cancel or insert buttons on the GridView). Any ideas? Thanks. Ekjon
-
Thanks to Abisodun and Mike for answering my previous post. Both of the answers was directed to the 2nd part of my question. On the first part, I still need help. So - here's it again: I am using MultiView / View controls which change by MenuItem clicks. Each view has a GridView on it with Edit and Insert features. The problem is: when the edit button is clicked, the GridView disappears and you need to click on the MenuItem again to see it (it happens evrytime you click edit, update, cancel or insert buttons on the GridView). Any ideas? Thanks. Ekjon
As I said in previous post, you might miss to bind the dataset in your pageload after postback... Can you show us what you wrote in PageLoad and Edit event?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
As I said in previous post, you might miss to bind the dataset in your pageload after postback... Can you show us what you wrote in PageLoad and Edit event?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Hi Michael, Here's what I'm doing: for the common part of the page, I am using dataset to populate some textbox controls, then for the details part - I'm using GridViews with a SqlDataSources. Each of the GridViews are placed on a View control being changed by MenuItem clicks. Here are some code: protected void Page_Init(object sender, EventArgs e) { projectId = Convert.ToInt32(Session["ClickedId"]); string [] dataKeys = {"MethodSID"}; conn = new SqlConnection(); // Get the ConnectionString dynamically conn.ConnectionString = ConfigurationManager.ConnectionStrings["EEM-NEWConnectionString1"].ConnectionString; dsrcMethods.ConnectionString = conn.ConnectionString; Parameter param; dsrcMethods.UpdateCommand = "update tblMethod set MethodName=@MethodName, MethodDesc=@MethodDesc," + "TaxonomicalKeys=@TaxonomicalKeys, TaxonomicalDesc=@TaxonomicalDesc" + " where MethodSID=@MethodSID and ProjectID=" + projectId; dsrcMethods.InsertCommand = "insert into tblMethod (ProjectID, MethodName, MethodDesc, TaxonomicalKeys," + " TaxonomicalDesc) values (" + projectId + ",@MethodName,@MethodDesc," + " @TaxonomicalKeys,@TaxonomicalDesc)"; param = new Parameter("MethodSID", TypeCode.Int32); dsrcMethods.UpdateParameters.Add(param); param = new Parameter("MethodName", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("MethodDesc", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("TaxonomicalKeys", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("TaxonomicalDesc", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); gvMethods.DataKeyNames = dataKeys; gvMethods.DataSourceID = dsrcMethods.ID; } protected void Page_Load(object sender, EventArgs e) { txtID.Focus(); txtID.Enabled = false; txtTitle.Enabled = false; txtAbstract.Enabled = false; txtJust.Enabled = false; txtSponsor.Enabled = false; txtStart
-
Hi Michael, Here's what I'm doing: for the common part of the page, I am using dataset to populate some textbox controls, then for the details part - I'm using GridViews with a SqlDataSources. Each of the GridViews are placed on a View control being changed by MenuItem clicks. Here are some code: protected void Page_Init(object sender, EventArgs e) { projectId = Convert.ToInt32(Session["ClickedId"]); string [] dataKeys = {"MethodSID"}; conn = new SqlConnection(); // Get the ConnectionString dynamically conn.ConnectionString = ConfigurationManager.ConnectionStrings["EEM-NEWConnectionString1"].ConnectionString; dsrcMethods.ConnectionString = conn.ConnectionString; Parameter param; dsrcMethods.UpdateCommand = "update tblMethod set MethodName=@MethodName, MethodDesc=@MethodDesc," + "TaxonomicalKeys=@TaxonomicalKeys, TaxonomicalDesc=@TaxonomicalDesc" + " where MethodSID=@MethodSID and ProjectID=" + projectId; dsrcMethods.InsertCommand = "insert into tblMethod (ProjectID, MethodName, MethodDesc, TaxonomicalKeys," + " TaxonomicalDesc) values (" + projectId + ",@MethodName,@MethodDesc," + " @TaxonomicalKeys,@TaxonomicalDesc)"; param = new Parameter("MethodSID", TypeCode.Int32); dsrcMethods.UpdateParameters.Add(param); param = new Parameter("MethodName", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("MethodDesc", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("TaxonomicalKeys", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); param = new Parameter("TaxonomicalDesc", TypeCode.String); dsrcMethods.UpdateParameters.Add(param); dsrcMethods.InsertParameters.Add(param); gvMethods.DataKeyNames = dataKeys; gvMethods.DataSourceID = dsrcMethods.ID; } protected void Page_Load(object sender, EventArgs e) { txtID.Focus(); txtID.Enabled = false; txtTitle.Enabled = false; txtAbstract.Enabled = false; txtJust.Enabled = false; txtSponsor.Enabled = false; txtStart
Try like that.. In Page_load
if (!Page.IsPostBack){ //Getting the data from database //Bind the data to Gridview // Add this datasource to cache or session (e.g. Cache["mydata"]= dsProject.Table[0]; ) } else{ //Re-bind the gridview with datasource from cache. (e.g. GridView1.DataSource = (DataTable)Cache["mydata"];) }
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)