Hi there,
I have a gridview (gvList), that I would like to populate programatically from a class and then use the rowedit features. Is this possible, or do I need to create some type of custom control? Currently, I've used a SqlDataSource for testing purposes. For example:
<asp:GridView ID="gvList" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" AutoGenerateEditButton="true" DataKeyNames="ID" AllowSorting="true" AllowPaging="false" OnRowEditing="gvList_RowEditing" OnRowUpdating="gvList_RowUpdating" ShowFooter="true">
<Columns>
<asp:BoundField HeaderText="Volume" DataField="StartVolume" SortExpression="StartVolume" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" UpdateCommand="UPDATE tbl_JournalVolumes SET StartVolume = @StartVolume WHERE ID = @ID" ConnectionString="<%$ ConnectionStrings:DB_1 %>" ></asp:SqlDataSource>
C#
if (this.JournalInfo != null)
{
SqlDataSource1.SelectCommand = "SELECT ID, StartVolume FROM tbl_JournalVolumes WHERE tbl_JournalVolumes.JournalID = " + jItm.ID.ToString();
}
I would like to instead BindData using this, or similar:
CMSLibrary.JournalVolumesDB jvDB = new CMSLibrary.JournalVolumesDB();
CMSLibrary.JournalVolumesInfo[] jvAll = jvDB.JournalVolumes_GetAllByJournalIDIgnoreStatus(this.JournalInfo.ID);
gvList.DataSource = jvAll;
gvList.DataBind();
I guess I'm wondering if I can assume jvAll to the SqlDataSource? I also have a class built to update the necessary SQL tables (jvDB.JournalVolumes_EditJournalVolumeSettings). Can this be assigned somehow to the SqlDataSource? Or, can I throw out the SqlDataSource and use some other method to bind and edit data line by line?
Thanks!