C#:
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- try
- {
- //1.重新綁定
- GridView1.EditIndex = e.NewEditIndex;
- //2.重新DataBind
- Gvlistitem.DataSource = dt;
- GridView1.DataBind();
- }
- catch (Exception)
- {
- throw;
- }
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- try
- {
- //1.重新綁定
- GridView1.EditIndex = e.NewEditIndex;
- //2.重新DataBind
- Gvlistitem.DataSource = dt;
- GridView1.DataBind();
- }
- catch (Exception)
- {
- throw;
- }
- }
- <asp:Panel ID="pan_RadioButton1" runat="server">
- <asp:RadioButton ID="rbtempty" runat="server" GroupName="ProjectType" Text="Empty project without any defaults." /><br />
- <asp:RadioButton ID="rbtcopy" runat="server" GroupName="ProjectType" Text="Copy an existing project." />
- <asp:DropDownList ID="ddlcopymodel" runat="server" Width="100"></asp:DropDownList>
- </asp:Panel>
- <asp:Button ID="btnSave" runat="server" Text="Save" Width="100" OnClientClick="return confirm('Do you really want to save?');" OnClick="btnSave_Click" />
- <asp:Button ID="btnprojecttypecancel" runat="server" Text="Cancel" Width="100" />
- protected void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- string r_id = "";
- string r_value = "";
- foreach (Control ctrl in pan_RadioButton1.Controls)//pan_RadioButton1這是Panel物件,取出Panel中所有物件
- {
- if (ctrl.GetType().Name == "RadioButton") //判斷物件是否為RadioButton
- {
- RadioButton rbt = ctrl as RadioButton; //將ctrl建立成RadioButton物件
- if (rbt.Checked) //判斷RadioButton是否被選取
- {
- r_id = rbt.ID.ToString();
- r_value = rbt.Text;
- }
- }
- }
- }
- catch (Exception)
- {
- throw;
- }
- }