Sunday 6 November 2011

Common Small Solutions C#.Net


find control on footrow of gridview

Label7.Text =((Label)GridViewBoxTemp.FooterRow.Cells[2].FindControl("FootLabelRate")).Text;


In Row Bound

 Label lblTotalPrice = (Label)e.Row.FindControl("LabelTQ");

In normal

((Label)GridView1.Rows[e.RowIndex].FindControl("Labelid")).Text);


Return 0 if field value is null
select Max(isnull(Process_ID,0)) as process from tbl_Processing




Date time Exceed by months

using System.Globalization;

  protected void DropEMISchedule_SelectedIndexChanged(object sender, EventArgs e)
    {
        DateTime dt;
       
        int calcy = Convert.ToInt32(DropEMISchedule.SelectedValue) * Convert.ToInt32(txttenure.Text);
        if (DateTime.TryParseExact(txtEMIStartDate.Text, "dd/MM/yyyy",new CultureInfo("en-US"), System.Globalization.DateTimeStyles.None, out dt))
        {
            TextBoxend.Text = "";
            DateTime dtshow = dt.Date.AddMonths(calcy);
            TextBoxend.Text = (dtshow).ToString("dd/MM/yyyy");
        
        }

      
      
    }




Pass Dataset in Session From One Page To Another




just add this
dataset st;
st=(DataSet)Session["SelectionD"];


to make dataset know what kind of value its in session





 No Datasource type display in data source configruation wizard

Its Due to the Becoz you have added chart controls(or any thing)
and you forget to see that there is some thing wrong in toolbox on left side pane!
so just open it!
got it?
Actually you have two tabs with same name 'Data' just right click on the new tab(like tab which contain chart control) and rename it to any thing else like i have changed it to 'Chart Data'!
It will work fine!
ask me if you have any question!


Execute Scaler Use To Count Rows

SqlCommand cmd = new SqlCommand("select count(EnrollmentNo) From Admission where EnrollmentNo='" + txt_enrollmentno.Text + "'", con);
      
int count = Convert.ToInt32(cmd.ExecuteScalar());

        if (count != 0)
        {

            //You Have Entered Enrollment No Which Is Already Exist Please Enter Diffrent Enrollment No!'

        }
        else
        {
           //'Valid Enrollment ....You Can Proceed
        }


Add value to SqlCommand :
cmd.Parameters.AddWithValue("@userName", userName);



Substring Value

int ind = 0;

 int len =4;
Label1.Text = TextBox1.Text.Substring(ind, len);

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...