Click here to Skip to main content
15,887,895 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Asp.Net Notifiation Push Pin
Richard Deeming19-Feb-14 2:33
mveRichard Deeming19-Feb-14 2:33 
QuestionSending free sms through ASP.Net Pin
Sharath Madhav18-Feb-14 23:34
Sharath Madhav18-Feb-14 23:34 
AnswerRe: Sending free sms through ASP.Net Pin
Tom Marvolo Riddle19-Feb-14 0:05
professionalTom Marvolo Riddle19-Feb-14 0:05 
QuestionREST service using classic ASP Pin
Subin Mavunkal18-Feb-14 22:00
Subin Mavunkal18-Feb-14 22:00 
SuggestionRe: REST service using classic ASP Pin
Richard Deeming19-Feb-14 2:31
mveRichard Deeming19-Feb-14 2:31 
GeneralRe: REST service using classic ASP Pin
Subin Mavunkal19-Feb-14 23:43
Subin Mavunkal19-Feb-14 23:43 
AnswerRe: REST service using classic ASP Pin
thatraja19-Feb-14 3:54
professionalthatraja19-Feb-14 3:54 
QuestionAssign code behind value to <EditItemTemplate> and <ItemTemplate> in Grid View Pin
indian14318-Feb-14 14:52
indian14318-Feb-14 14:52 
hi all,

I am using a GridView in my aspx page I want make the fields editable or non editable depending upon a field in page Code behind and another thing is that the bound column is also not getting values that I am assigning for code behind. Can anybody please look into my code and let me know, where am I doing mistake.
Please help me by giving suggestion where am I doing mistake or by showing any link for example. I am also researching regarding this. Any kind of help is appreciated. thanks in advance. For assigning values both the "" and '' aren't working I don't know why?

Here is my aspx html code:
           <asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False"
               OnRowEditing="gv1_RowEditing" OnRowCancelingEdit="gv1_RowCancelingEdit"
               OnRowUpdating="gv1_RowUpdating" CellPadding="4" ForeColor="#333333">
               <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
               <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
               <Columns>
                   <asp:CommandField ShowEditButton="True" />
                   <asp:BoundField DataField="RecipientAgency" HeaderText="Recipient Agency" InsertVisible="False"
                       ReadOnly="True" SortExpression="RecipientAgency" />
                   <asp:TemplateField HeaderText="Carry Over Year" InsertVisible="False" SortExpression="CarryOverYear">
                       <EditItemTemplate>
                           <asp:TextBox ID="txtCarryOverYear" runat="server" Visible="<%# IsInEditMode %>" Text='<%# Bind("CarryOverYear") %>'></asp:TextBox>
                       </EditItemTemplate>
                       <ItemTemplate>
                           <asp:Label ID="lblCarryOverYear" runat="server" Visible='<%# !(bool) IsInEditMode %>' Text='<%# Bind("CarryOverYear") %>'></asp:Label>
                           <asp:TextBox ID="txtCarryOverYear" runat="server" Visible="<%# IsInEditMode %>" Text='<%# Bind("CarryOverYear") %>'></asp:TextBox>
                       </ItemTemplate>
                   </asp:TemplateField>
                   <asp:TemplateField HeaderText="Diverted Year" InsertVisible="False" SortExpression="DivertedYear">
                       <EditItemTemplate>
                           <asp:TextBox ID="txtDivertedYear" runat="server" Visible='<%# IsInEditMode %>' Text='<%# Bind("DivertedYear") %>'></asp:TextBox>
                       </EditItemTemplate>
                       <ItemTemplate>
                           <asp:Label ID="lblDivertedYear" runat="server" Visible='<%# !(bool) IsInEditMode %>' Text='<%# Bind("DivertedYear") %>'></asp:Label>
                           <asp:TextBox ID="txtDivertedYear" runat="server" Visible='<%# IsInEditMode %>' Text='<%# Bind("DivertedYear") %>'></asp:TextBox>
                       </ItemTemplate>
                   </asp:TemplateField>
                   <asp:TemplateField HeaderText="Jul" SortExpression="Jul">
                       <EditItemTemplate>
                           <asp:TextBox ID="txtJul" runat="server" Visible='<%# IsInEditMode %>' Text='<%# Bind("Jul") %>'></asp:TextBox>
                       </EditItemTemplate>
                       <ItemTemplate>
                           <asp:Label ID="lblJul" runat="server" Visible='<%# !(bool) IsInEditMode %>' Text='<%# Bind("Jul") %>'></asp:Label>
                           <asp:TextBox ID="txtJul" runat="server" Visible='<%# IsInEditMode %>' Text='<%# Bind("Jul") %>'></asp:TextBox>
                       </ItemTemplate>
                   </asp:TemplateField>
</Columns>
               <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
               <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
               <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
               <EditRowStyle BackColor="#999999" />
               <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
           </asp:GridView>

And Here is my code behind code that tries to manipulate the gridview appearance and values:
public partial class MonthlyPerformance : System.Web.UI.Page
{
    protected bool IsInEditMode=false;


    protected void gv1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        IsInEditMode = true;
        var temp = ((TextBox)gv1.Rows[e.NewEditIndex].FindControl("txtCarryOverYear"));
        var t=temp.Visible;// = IsInEditMode;
    }

    protected void gv1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        IsInEditMode = false;
        e.Cancel = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        LoadList();
    }

    protected void gv1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
    }
    private void LoadList()
    {
        string strSQL;
        DataSet ds = null;
        IDataReader dr = null;
        double Total = 0;

        DataSet dsByHand = new DataSet();
        dsByHand.Tables.Add();

        //ds.Tables[0].NewRow();
        //dsByHand.Tables[0].Rows.Add(dsByHand.Tables[0].NewRow());

        dsByHand.Tables[0].Columns.Add("RecipientAgency");
        dsByHand.Tables[0].Columns.Add("CarryOverYear");
        dsByHand.Tables[0].Columns.Add("DivertedYear");
        dsByHand.Tables[0].Columns.Add("Jul");
        dsByHand.Tables[0].Columns.Add("Aug");
        dsByHand.Tables[0].Columns.Add("Sep");
        dsByHand.Tables[0].Columns.Add("Oct");
        dsByHand.Tables[0].Columns.Add("Nov");
        dsByHand.Tables[0].Columns.Add("Dec");
        dsByHand.Tables[0].Columns.Add("Jan");
        dsByHand.Tables[0].Columns.Add("Feb");
        dsByHand.Tables[0].Columns.Add("Mar");
        dsByHand.Tables[0].Columns.Add("Apr");
        dsByHand.Tables[0].Columns.Add("May");
        dsByHand.Tables[0].Columns.Add("Jun");
        dsByHand.Tables[0].Columns.Add("TotalProductProduced");
        dsByHand.Tables[0].Columns.Add("TransfToState");
        dsByHand.Tables[0].Columns.Add("Adjustment");
        dsByHand.Tables[0].Columns.Add("EndingBalance");
        var tempr = dsByHand.Tables[0].NewRow();
        tempr.ItemArray[0] = "Test Temp";
        dsByHand.Tables[0].Rows.Add(tempr);

        gv1.DataSource = dsByHand.Tables[0];
        gv1.AutoGenerateColumns = false;
        gv1.DataBind();

    }
}//end of class

Thanks & Regards,

Abdul Aleem Mohammad
St Louis MO - USA

AnswerRe: Assign code behind value to <EditItemTemplate> and <ItemTemplate> in Grid View Pin
Tom Marvolo Riddle18-Feb-14 21:03
professionalTom Marvolo Riddle18-Feb-14 21:03 
QuestionRegarding Paypal integration Pin
Rockstar_18-Feb-14 0:28
professionalRockstar_18-Feb-14 0:28 
AnswerRe: Regarding Paypal integration Pin
jkirkerx18-Feb-14 9:30
professionaljkirkerx18-Feb-14 9:30 
AnswerRe: Regarding Paypal integration Pin
ZurdoDev18-Feb-14 15:17
professionalZurdoDev18-Feb-14 15:17 
GeneralRe: Regarding Paypal integration Pin
Rockstar_18-Feb-14 19:59
professionalRockstar_18-Feb-14 19:59 
AnswerRe: Regarding Paypal integration Pin
ZurdoDev19-Feb-14 1:55
professionalZurdoDev19-Feb-14 1:55 
QuestionASP.net E-commerce system Pin
dsakellariou17-Feb-14 23:01
dsakellariou17-Feb-14 23:01 
AnswerRe: ASP.net E-commerce system Pin
thatraja17-Feb-14 23:50
professionalthatraja17-Feb-14 23:50 
GeneralRe: ASP.net E-commerce system Pin
dsakellariou18-Feb-14 0:10
dsakellariou18-Feb-14 0:10 
AnswerRe: ASP.net E-commerce system Pin
jkirkerx18-Feb-14 9:48
professionaljkirkerx18-Feb-14 9:48 
GeneralRe: ASP.net E-commerce system Pin
dsakellariou18-Feb-14 20:14
dsakellariou18-Feb-14 20:14 
GeneralRe: ASP.net E-commerce system Pin
jkirkerx19-Feb-14 10:59
professionaljkirkerx19-Feb-14 10:59 
AnswerRe: ASP.net E-commerce system Pin
dharmegh25-Feb-14 1:53
dharmegh25-Feb-14 1:53 
GeneralRe: ASP.net E-commerce system Pin
dsakellariou25-Feb-14 2:31
dsakellariou25-Feb-14 2:31 
AnswerRe: ASP.net E-commerce system Pin
Alexander Siniouguine21-Aug-15 20:16
Alexander Siniouguine21-Aug-15 20:16 
AnswerRe: ASP.net E-commerce system Pin
Alexander Siniouguine21-Aug-15 19:54
Alexander Siniouguine21-Aug-15 19:54 
Questionhow to huge data processing in entity framework using mvc? Pin
vivekanandan, Ganeshan17-Feb-14 20:08
vivekanandan, Ganeshan17-Feb-14 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.