H
hamsterchaos
I have spent 3 months and have a good functioning .net appljcaiton,
where a table is populated from the mysql database, and you can insert
and update rows.
It uses:
MYSQL
Gridview component
ODBC connection
Unfortuantely this requires ALOT of manual coding, including, stating
the parameters to be used for each of the insert, update, select
statements ( you cant use Visual Studios GUI because Im connecting to
a MYSQL database).
It also invovles recoding all of the row updating methods, insert
methods , and on top of that use complex "find" statements to figure
out which text box to gather the input from.
I include examples below:
<EditItemTemplate>
<asp:TextBox ID="finishTXT" runat="server" Text='<%#
Eval("finish") %>' />
</EditItemTemplate></asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="right"
HeaderText="Length">
<ItemTemplate ><asp:literal ID="length" runat="server" Text='<%#
formatstart(Eval("length")) %>' /></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lengthTXT" runat="server" Text='<%#
Eval("length") %>' />
</EditItemTemplate></asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="right"
HeaderText="Room">
<ItemTemplate ><asp:literal ID="room" runat="server" Text='<%#
Eval("room") %>' /></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="roomTXT" runat="server" Text='<%# Eval("room")
%>' />
</EditItemTemplate></asp:TemplateField>
....
Name="amendmentMade" />
<asparameter Name="amendment" />
<asparameter Name="course split" />
<asparameter Name="group" />
<asparameter Name="class" />
<asparameter Name="banner code" />
<asparameter Name="person code" />
<asparameter Name="personcodeleadteacher" />
</InsertParameters>
<UpdateParameters>
<asparameter Name="day" />
<asparameter Name="dates" />
<asparameter Name="start" />
<asparameter Name="finish" />
....
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
Session["boobs"] = e.Row.RowIndex; ;
}
}
......
public void this_rowUpdating(Object sender,
GridViewUpdateEventArgs e)
{
int selectedrow = Convert.ToInt32(Session["boobs"]);
Box groupTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTgroup");
TextBox classTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTclass");
TextBox bannercodeTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTbannercode");
TextBox personcodeTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTpersoncode");
TextBox personcodeleadteacherTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTpersoncodeleadteacher");
e.NewValues["day"] = dayTXT.Text;
e.NewValues["dates"] = datesTXT.Text;
e.NewValues["start"] = startTXT.Text;
e.NewValues["finish"] = finishTXT.Text;
.....
public void gridChange(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
if (Page.IsValid)
{
TextBox txtGroup =
(TextBox)GridView1.FooterRow.FindControl("txtGroup");
TextBox txtBannerCode =
(TextBox)GridView1.FooterRow.FindControl("txtBannerCode");
if (Course.Text != null)
{
SqlDataSource1.InsertParameters["Course"].DefaultValue = Course.Text;
SqlDataSource1.InsertParameters["ID"].DefaultValue = txtId.Text;
SqlDataSource1.InsertParameters["Day"].DefaultValue = txtDay.Text;
.....
These are all examples of manual hand written code required for one
fully funciontal editable gridview in c# with mysql.
Am I being retarded? Is there a much easier way to do this?
Thanks for your time
where a table is populated from the mysql database, and you can insert
and update rows.
It uses:
MYSQL
Gridview component
ODBC connection
Unfortuantely this requires ALOT of manual coding, including, stating
the parameters to be used for each of the insert, update, select
statements ( you cant use Visual Studios GUI because Im connecting to
a MYSQL database).
It also invovles recoding all of the row updating methods, insert
methods , and on top of that use complex "find" statements to figure
out which text box to gather the input from.
I include examples below:
<EditItemTemplate>
<asp:TextBox ID="finishTXT" runat="server" Text='<%#
Eval("finish") %>' />
</EditItemTemplate></asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="right"
HeaderText="Length">
<ItemTemplate ><asp:literal ID="length" runat="server" Text='<%#
formatstart(Eval("length")) %>' /></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lengthTXT" runat="server" Text='<%#
Eval("length") %>' />
</EditItemTemplate></asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="right"
HeaderText="Room">
<ItemTemplate ><asp:literal ID="room" runat="server" Text='<%#
Eval("room") %>' /></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="roomTXT" runat="server" Text='<%# Eval("room")
%>' />
</EditItemTemplate></asp:TemplateField>
....
Name="amendmentMade" />
<asparameter Name="amendment" />
<asparameter Name="course split" />
<asparameter Name="group" />
<asparameter Name="class" />
<asparameter Name="banner code" />
<asparameter Name="person code" />
<asparameter Name="personcodeleadteacher" />
</InsertParameters>
<UpdateParameters>
<asparameter Name="day" />
<asparameter Name="dates" />
<asparameter Name="start" />
<asparameter Name="finish" />
....
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
Session["boobs"] = e.Row.RowIndex; ;
}
}
......
public void this_rowUpdating(Object sender,
GridViewUpdateEventArgs e)
{
int selectedrow = Convert.ToInt32(Session["boobs"]);
Box groupTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTgroup");
TextBox classTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTclass");
TextBox bannercodeTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTbannercode");
TextBox personcodeTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTpersoncode");
TextBox personcodeleadteacherTXT =
(TextBox)GridView1.Rows[selectedrow].Cells[4].FindControl("TXTpersoncodeleadteacher");
e.NewValues["day"] = dayTXT.Text;
e.NewValues["dates"] = datesTXT.Text;
e.NewValues["start"] = startTXT.Text;
e.NewValues["finish"] = finishTXT.Text;
.....
public void gridChange(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
if (Page.IsValid)
{
TextBox txtGroup =
(TextBox)GridView1.FooterRow.FindControl("txtGroup");
TextBox txtBannerCode =
(TextBox)GridView1.FooterRow.FindControl("txtBannerCode");
if (Course.Text != null)
{
SqlDataSource1.InsertParameters["Course"].DefaultValue = Course.Text;
SqlDataSource1.InsertParameters["ID"].DefaultValue = txtId.Text;
SqlDataSource1.InsertParameters["Day"].DefaultValue = txtDay.Text;
.....
These are all examples of manual hand written code required for one
fully funciontal editable gridview in c# with mysql.
Am I being retarded? Is there a much easier way to do this?
Thanks for your time