S
Steven Van Eyck
Hi there
There are probably lots of questions being posted about datagrids, but I
can't resist... ;-)
Here's my issue:
I have an aspx page with a datagrid in which I manually declare the columns
like this:
<aspataGrid ID="grdCampaigns" runat="server" BorderColor="#73C6EF"
GridLines="Vertical" CellPadding="2" CellSpacing="0" Width="100%"
Font-Name="Verdana" Font-Size="6px" HeaderStyle-CssClass="tableheader"
ItemStyle-BackColor="#FFFFFF" AlternatingItemStyle-BackColor="#FFFFCC"
AutoGenerateColumns="False">
<columns>
<asp:TemplateColumn HeaderText="ID">
<itemtemplate>
<asp:Label ID="colCampaignId" runat="server"
Text='<%# Container.DataItem("ID") %>'/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="40"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="CAMPAIGN">
<itemtemplate>
<asp:TextBox ID="colCampaign" runat="server"
Text='<%# Container.DataItem("CAMPAIGN") %>' MaxLength="50" Width="290"
CssClass="dropdown"/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="300"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="mob">
<itemtemplate>
<asp:CheckBox ID="colMobile" runat="server"
Checked='<%# Container.DataItem("MOBILE") %>'/>
</itemtemplate>
<itemstyle Width="50" HorizontalAlign="center"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="load">
<itemtemplate>
<asp:CheckBox ID="colLoader" runat="server"
Checked='<%# Container.DataItem("LOADER") %>'/>
</itemtemplate>
<itemstyle Width="50" HorizontalAlign="center"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="EFORM">
<itemtemplate>
<asp:TextBox ID="colEform" runat="server"
Text='<%# Container.DataItem("EFORM") %>' MaxLength="255"
CssClass="dropdown" Width="370"/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="380"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="">
<itemtemplate>
<asp:LinkButton ID="btnSave" runat="server"
OnClick="doSave"/>
<img
src="../general/images/buttons/squares/save-indication.gif" border="0"/>
</asp:LinkButton>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="20"/>
</asp:TemplateColumn>
</columns>
</aspataGrid>
Some code behind loads the data from my backend database into the datagrid
and that is working perfectly.
During this procedure, I add an empty row in the datagrid that the user can
use to create a new record.
The problem lies in the btnSave control. When the user clicks this button, I
want my code to know which row the user wan't to update/insert, but I can't
seem to get a reference to the exact row.
Does anybody know how to tackle this ?
Many thanks
There are probably lots of questions being posted about datagrids, but I
can't resist... ;-)
Here's my issue:
I have an aspx page with a datagrid in which I manually declare the columns
like this:
<aspataGrid ID="grdCampaigns" runat="server" BorderColor="#73C6EF"
GridLines="Vertical" CellPadding="2" CellSpacing="0" Width="100%"
Font-Name="Verdana" Font-Size="6px" HeaderStyle-CssClass="tableheader"
ItemStyle-BackColor="#FFFFFF" AlternatingItemStyle-BackColor="#FFFFCC"
AutoGenerateColumns="False">
<columns>
<asp:TemplateColumn HeaderText="ID">
<itemtemplate>
<asp:Label ID="colCampaignId" runat="server"
Text='<%# Container.DataItem("ID") %>'/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="40"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="CAMPAIGN">
<itemtemplate>
<asp:TextBox ID="colCampaign" runat="server"
Text='<%# Container.DataItem("CAMPAIGN") %>' MaxLength="50" Width="290"
CssClass="dropdown"/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="300"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="mob">
<itemtemplate>
<asp:CheckBox ID="colMobile" runat="server"
Checked='<%# Container.DataItem("MOBILE") %>'/>
</itemtemplate>
<itemstyle Width="50" HorizontalAlign="center"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="load">
<itemtemplate>
<asp:CheckBox ID="colLoader" runat="server"
Checked='<%# Container.DataItem("LOADER") %>'/>
</itemtemplate>
<itemstyle Width="50" HorizontalAlign="center"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="EFORM">
<itemtemplate>
<asp:TextBox ID="colEform" runat="server"
Text='<%# Container.DataItem("EFORM") %>' MaxLength="255"
CssClass="dropdown" Width="370"/>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="380"/>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="">
<itemtemplate>
<asp:LinkButton ID="btnSave" runat="server"
OnClick="doSave"/>
<img
src="../general/images/buttons/squares/save-indication.gif" border="0"/>
</asp:LinkButton>
</itemtemplate>
<itemstyle HorizontalAlign="center" Width="20"/>
</asp:TemplateColumn>
</columns>
</aspataGrid>
Some code behind loads the data from my backend database into the datagrid
and that is working perfectly.
During this procedure, I add an empty row in the datagrid that the user can
use to create a new record.
The problem lies in the btnSave control. When the user clicks this button, I
want my code to know which row the user wan't to update/insert, but I can't
seem to get a reference to the exact row.
Does anybody know how to tackle this ?
Many thanks