Using LINQ with MySQL in C#

Last Reply on Oct 07, 2012 11:50 PM By komaldeep

Posted on Oct 06, 2012 06:12 AM

sir,

I used ur code while developing some of my modules and they work fantastic...now i have a prob was working on that from last week bt unable to correct it can u plz help m out??

I have a textbox under that i have taken a checkbox that is giving input in form of 1 or 0

and under that i have taken a gridview in which my column name is ID,name and Ismain with a radiobutton what i want is that when i select checkbox the ismain should give value 1 or 0 else when i select radiobutton  Ismain should give the same value as Id....

hope to have a positive rply from ur side...

thanks in advance..

i have done this using linq..This is what i have done till nw 

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
            fillgrid();
        }
          
    }

    protected void btnsub_Click(object sender, EventArgs e)
    {
        masterdataDataContext db = new masterdataDataContext();
        {
          
                string name = txtname.Text.ToString();
                int IsMain = Convert.ToInt32(Chckmain.Checked);
                 int checkBoxVal;
                if (Chckmain.Checked)
                {

                    checkBoxVal = 1;
                }


                db.getdata(name, IsMain);
                db.SubmitChanges();
                fillgrid();


        
}
    }
   protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       fillgrid();
   }

   public void fillgrid()
   {
       masterdataDataContext db = new masterdataDataContext();
       var categories = db.getalldata();
       GridView1.DataSource = categories.ToList();
       GridView1.DataBind();
   }
   
 
      
}

 

 

 

 

Posted on Oct 06, 2012 06:12 AM

What is your problem here?


Posted on Oct 07, 2012 11:50 PM

sir,

what i want is suppose nw i select radiobutton from a grid view then on the selection of submit button it show next row its ID should be increased n the selected radiobutton ID should be equal tom Ismain and the name should be as it is the ID selected previously..

 

this is my asp page

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    
</head>
<script language="javascript" type="text/javascript">
function SelectSingleRadiobutton(rdbtnid) 
{
var rdBtn = document.getElementById(rdbtnid);
var rdBtnList = document.getElementsByTagName("input");
for (i = 0; i < rdBtnList.length; i++)
 {
if (rdBtnList[i].type == "radio" && rdBtnList[i].id != rdBtn.id)
{
rdBtnList[i].checked = false;
}
}
}
   </script>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Label ID="lblnam" runat="server" Text="Enter Name"></asp:Label>
&nbsp;<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="Lblmain" runat="server" Text="IS Main"></asp:Label>
    
    &nbsp;<asp:CheckBox ID="Chckmain" runat="server" AutoPostBack = "true" Enabled="true" />
    
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnsub" runat="server" Text="Submit" onclick="btnsub_Click" />
    
    </div>
<p>
    &nbsp;</p>
    
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        OnRowCommand="GridView1_RowCommand" 
           >
            <Columns>
            <asp:TemplateField HeaderText="Select">
            <ItemTemplate>
          <asp:RadioButton id="rdbUser" runat="server" OnClick="javascript:SelectSingleRadiobutton(this.id)"  />
           
            </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="ID">
            <ItemTemplate>
                    <asp:Label ID="lbld" runat="server" Text='<%#Eval("Id") %>'></asp:Label>
                </ItemTemplate>
                 </asp:TemplateField>
            <asp:TemplateField HeaderText="Name">
            <ItemTemplate>
                    <asp:Label ID="lblnam" runat="server" Text='<%#Eval("name") %>'></asp:Label>
                </ItemTemplate>
                 </asp:TemplateField>
            <asp:TemplateField HeaderText="IsMain">
            <ItemTemplate>
                    <asp:Label ID="lblmain" runat="server" Text='<%#Eval("IsMain ") %>'></asp:Label>
                </ItemTemplate>
                 </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </form>
</body>
</html>